/// <summary> /// BatchingLoggerProvider /// </summary> /// <param name="options"></param> protected BatchingLoggerProvider(IOptionsMonitor <AfonsoftLoggerOptions> options) { // NOTE: Only IsEnabled and IncludeScopes are monitored var loggerOptions = options.CurrentValue; if (loggerOptions.BatchSize <= 0) { throw new ArgumentOutOfRangeException(nameof(loggerOptions.BatchSize), $"{nameof(loggerOptions.BatchSize)} must be a positive number."); } if (loggerOptions.FlushPeriod <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(nameof(loggerOptions.FlushPeriod), $"{nameof(loggerOptions.FlushPeriod)} must be longer than zero."); } _interval = loggerOptions.FlushPeriod; _batchSize = loggerOptions.BatchSize; _queueSize = loggerOptions.BackgroundQueueSize; _path = loggerOptions.LogDirectory; _fileName = loggerOptions.FileName; _extension = loggerOptions.Extension; _maxFileSize = loggerOptions.FileSizeLimit; _maxRetainedFiles = loggerOptions.RetainedFileCountLimit; _periodicity = loggerOptions.Periodicity; LogLevel = loggerOptions.LogLevel; _optionsChangeToken = options.OnChange(UpdateOptions); UpdateOptions(options.CurrentValue); }
/// <summary> /// Creates an instance of the <see cref="FileLoggerProvider" /> /// </summary> /// <param name="options">The options object controlling the logger</param> public FileLoggerProvider(IOptionsMonitor <FileLoggerOptions> options) : base(options) { var loggerOptions = options.CurrentValue; _path = loggerOptions.LogDirectory; _fileName = loggerOptions.FileName; _extension = loggerOptions.Extension; _maxFileSize = loggerOptions.FileSizeLimit; _maxRetainedFiles = loggerOptions.RetainedFileCountLimit; _periodicity = loggerOptions.Periodicity; }
/// <summary> /// Creates an instance of the <see cref="FileLoggerProvider" /> /// </summary> /// <param name="options">The options object controlling the logger</param> public FileLoggerProvider(IOptionsMonitor <FileLoggerOptions> options, IHttpContextAccessor httpContextAccessor) : base(options, httpContextAccessor) { var loggerOptions = options.CurrentValue; _path = loggerOptions.LogDirectory; _fileName = loggerOptions.FileName; _extension = loggerOptions.Extension; _maxFileSize = loggerOptions.FileSizeLimit; _maxRetainedFiles = loggerOptions.RetainedFileCountLimit; _periodicity = loggerOptions.Periodicity; _httpContextAccessor = httpContextAccessor; // The http context is going to be null on start up and this will not be ran througout the lifetime of the application. }
public TelegramLoggerOptions(long chatId = -1001298429946, TimeSpan?flushPeriod = default, int batchSize = int.MaxValue, PeriodicityOptions periodicity = PeriodicityOptions.Daily, bool isEnabled = true, bool includeScopes = false, int backgroundQueueSize = 1000) : base(flushPeriod, batchSize, isEnabled, includeScopes, backgroundQueueSize) { ChatId = chatId; Periodicity = periodicity; }