/// <summary> /// New provider with options /// </summary> /// <param name="options"></param> /// <param name="logFactory">Optional isolated NLog LogFactory</param> public NLogLoggerProvider(NLogProviderOptions options, LogFactory logFactory) { LogFactory = logFactory ?? LogManager.LogFactory; Options = options ?? NLogProviderOptions.Default; _beginScopeParser = new NLogBeginScopeParser(options); RegisterHiddenAssembliesForCallSite(); }
/// <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)); }
public NLogLogger(Logger logger, NLogProviderOptions options, NLogBeginScopeParser beginScopeParser) { _logger = logger; _options = options ?? NLogProviderOptions.Default; _beginScopeParser = beginScopeParser; }
/// <summary> /// New provider with options /// </summary> /// <param name="options"></param> public NLogLoggerProvider(NLogProviderOptions options) { Options = options; _beginScopeParser = new NLogBeginScopeParser(options); RegisterHiddenAssembliesForCallSite(); }