// Internal overload with parameters used by tests to override the config section and inject mocks
        internal static LoggerConfiguration MSSqlServerInternal(
            this LoggerSinkConfiguration loggerConfiguration,
            string connectionString,
            MSSqlServerSinkOptions sinkOptions,
            IConfigurationSection sinkOptionsSection,
            IConfiguration appConfiguration,
            LogEventLevel restrictedToMinimumLevel,
            IFormatProvider formatProvider,
            ColumnOptions columnOptions,
            IConfigurationSection columnOptionsSection,
            ITextFormatter logEventFormatter,
            IApplySystemConfiguration applySystemConfiguration,
            IApplyMicrosoftExtensionsConfiguration applyMicrosoftExtensionsConfiguration,
            IMSSqlServerSinkFactory sinkFactory,
            IPeriodicBatchingSinkFactory batchingSinkFactory)
        {
            if (loggerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(loggerConfiguration));
            }

            ReadConfiguration(ref connectionString, ref sinkOptions, sinkOptionsSection, appConfiguration,
                              ref columnOptions, columnOptionsSection, applySystemConfiguration, applyMicrosoftExtensionsConfiguration);

            var sink = sinkFactory.Create(connectionString, sinkOptions, formatProvider, columnOptions, logEventFormatter);

            var periodicBatchingSink = batchingSinkFactory.Create(sink, sinkOptions);

            return(loggerConfiguration.Sink(periodicBatchingSink, restrictedToMinimumLevel));
        }
Example #2
0
        // Internal overload with parameters used by tests to override the config section and inject mocks
        internal static LoggerConfiguration MSSqlServerInternal(
            this LoggerSinkConfiguration loggerConfiguration,
            string configSectionName,
            string connectionString,
            SinkOptions sinkOptions = null,
            LogEventLevel restrictedToMinimumLevel             = LevelAlias.Minimum,
            IFormatProvider formatProvider                     = null,
            ColumnOptions columnOptions                        = null,
            ITextFormatter logEventFormatter                   = null,
            IApplySystemConfiguration applySystemConfiguration = null,
            IMSSqlServerSinkFactory sinkFactory                = null)
        {
            if (loggerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(loggerConfiguration));
            }

            ReadConfiguration(configSectionName, ref connectionString, ref sinkOptions, ref columnOptions, applySystemConfiguration);

            var sink = sinkFactory.Create(connectionString, sinkOptions, formatProvider, columnOptions, logEventFormatter);

            return(loggerConfiguration.Sink(sink, restrictedToMinimumLevel));
        }