Beispiel #1
0
        /// <summary>
        /// Begin a scope. Use in config with ${ndlc}
        /// </summary>
        /// <param name="state">The state (message)</param>
        /// <returns></returns>
        public IDisposable BeginScope <TState>(TState state)
        {
            if (!_options.IncludeScopes || state == null)
            {
                return(NullScope.Instance);
            }

            if (_options.CaptureMessageProperties)
            {
                return(_beginScopeParser.ParseBeginScope(state) ?? NullScope.Instance);
            }

            return(NLogBeginScopeParser.CreateDiagnosticLogicalContext(state) ?? NullScope.Instance);
        }
        /// <summary>
        /// Begin a scope. Use in config with ${ndlc}
        /// </summary>
        /// <param name="state">The state (message)</param>
        /// <returns></returns>
        public IDisposable BeginScope <TState>(TState state)
        {
            if (!_options.IncludeScopes)
            {
                return(NullScope.Instance);
            }

            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            if (_beginScopeParser != null)
            {
                return(_beginScopeParser.ParseBeginScope(state));
            }

            return(NLogBeginScopeParser.CreateDiagnosticLogicalContext(state));
        }