/// <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 (_beginScopeParser != null)
            {
                return(_beginScopeParser.ParseBeginScope(state) ?? NullScope.Instance);
            }

            return(NLogBeginScopeParser.CreateDiagnosticLogicalContext(state) ?? NullScope.Instance);
        }
示例#2
0
 /// <summary>
 /// New provider with options
 /// </summary>
 /// <param name="options"></param>
 public NLogLoggerProvider(NLogProviderOptions options)
 {
     Options           = options ?? NLogProviderOptions.Default;
     _beginScopeParser = new NLogBeginScopeParser(options);
     RegisterHiddenAssembliesForCallSite();
 }
 public NLogLogger(Logger logger, NLogProviderOptions options, NLogBeginScopeParser beginScopeParser)
 {
     _logger           = logger;
     _options          = options ?? NLogProviderOptions.Default;
     _beginScopeParser = beginScopeParser;
 }