public SerilogLoggerScope(SerilogLoggerProvider provider, object state, IDisposable chainedDisposable = null)
        {
            _provider = provider;
            _state    = state;

            Parent = _provider.CurrentScope;
            _provider.CurrentScope = this;
            _chainedDisposable     = chainedDisposable;
        }
Exemple #2
0
        public SerilogLoggerScope(SerilogLoggerProvider provider, string name, object state)
        {
            _provider = provider;
            Name      = name;
            State     = state;

            Parent = _provider.CurrentScope;
            _provider.CurrentScope = this;
        }
Exemple #3
0
        public SerilogLoggerScope(SerilogLoggerProvider provider, object state)
        {
            _provider = provider;
            _state    = state;

            Parent = _provider.CurrentScope;
            _provider.CurrentScope = this;
            _popSerilogContext     = LogContext.PushProperties(this);
        }
        public SerilogLoggerScope(SerilogLoggerProvider provider, string name, object state)
        {
            _provider = provider;
            Name = name;
            State = state;

            Parent = _provider.CurrentScope;
            _provider.CurrentScope = this;
        }
        public SerilogLogger(
            SerilogLoggerProvider provider,
            ILogger logger = null,
            string name    = null)
        {
            _provider = provider ?? throw new ArgumentNullException(nameof(provider));

            // If a logger was passed, the provider has already added itself as an enricher
            _logger = logger ?? Serilog.Log.Logger.ForContext(new[] { provider });

            if (name != null)
            {
                _logger = _logger.ForContext(Constants.SourceContextPropertyName, name);
            }
        }
        public SerilogLogger(
            SerilogLoggerProvider provider,
            ILogger logger = null,
            string name = null)
        {
            if (provider == null) throw new ArgumentNullException(nameof(provider));
            _provider = provider;
            _name = name;
            _logger = logger;

            // If a logger was passed, the provider has already added itself as an enricher
            _logger = _logger ?? Serilog.Log.Logger.ForContext(new[] { provider });

            if (_name != null)
            {
                _logger = _logger.ForContext(Constants.SourceContextPropertyName, name);
            }
        }
Exemple #7
0
        public SerilogLogger(
            SerilogLoggerProvider provider,
            Logger logger,
            string name = null)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            _provider = provider ?? throw new ArgumentNullException(nameof(provider));

            _logger = logger.ForContext(new[] { provider });

            if (name != null)
            {
                _logger = _logger.ForContext(Constants.SourceContextPropertyName, name);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SerilogLoggerFactory"/> class.
 /// </summary>
 /// <param name="logger">The Serilog logger; if not supplied, the static <see cref="Serilog.Log"/> will be used.</param>
 /// <param name="dispose">When true, dispose <paramref name="logger"/> when the framework disposes the provider. If the
 /// logger is not specified but <paramref name="dispose"/> is true, the <see cref="Log.CloseAndFlush()"/> method will be
 /// called on the static <see cref="Log"/> class instead.</param>
 /// <param name="providerCollection">A <see cref="LoggerProviderCollection"/>, for use with <c>WriteTo.Providers()</c>.</param>
 public SerilogLoggerFactory(ILogger logger = null, bool dispose = false, LoggerProviderCollection providerCollection = null)
 {
     _provider           = new SerilogLoggerProvider(logger, dispose);
     _providerCollection = providerCollection;
 }