/// <summary> /// Initializes a new instance of the <see cref="ResponseLog" /> class. /// </summary> /// <param name="options">The configured <see cref="SqlServerLoggingOptions" />.</param> /// <param name="locations">The configured <see cref="LocationStore" />.</param> /// <param name="environment">The environment context.</param> public ResponseLog(SqlServerLoggingOptions options, ILocationStore locations, ApplicationInformation environment) : base(options.BatchSize, options.Period) { Argument.NotNull(options, nameof(options)); Argument.NotNull(locations, nameof(locations)); Argument.NotNull(environment, nameof(environment)); _options = options; _locations = locations; _environment = environment; _eventsTable = this.CreateTable(); }
/// <summary> /// Adds the SQL Server Auditing block to the container. /// </summary> /// <param name="instance">The this instance.</param> /// <param name="configuration">The configuration routine.</param> /// <returns>Returns the container instance for method chaining.</returns> public static Stack UseSqlServerLogging(this Stack instance, Action <SqlServerLoggingOptions> configuration = null) { Argument.NotNull(instance, nameof(instance)); instance.Include(typeof(Configuration).Assembly); var options = new SqlServerLoggingOptions(); configuration?.Invoke(options); instance.Configuration.GetSection("Stacks:Logging:SqlServer").Bind(options); instance.Use(builder => { builder.RegisterModule(new SqlServerLoggingModule(options)); }); return(instance); }
/// <summary> /// Initializes a new instance of the <see cref="SqlLogger" /> class. /// </summary> /// <param name="options">The configured <see cref="SqlServerLoggingOptions" />.</param> /// <param name="policies">The configured <see cref="IDestructuringPolicy" /> instances.</param> /// <param name="locations">The configured <see cref="LocationStore" />.</param> public SqlLogger(SqlServerLoggingOptions options, IEnumerable <IDestructuringPolicy> policies, ILocationStore locations) { Argument.NotNull(options, nameof(options)); var columnOptions = new ColumnOptions(); // Don't include the Properties XML column. columnOptions.Store.Remove(StandardColumn.Properties); // Do include the log event data as JSON. columnOptions.Store.Add(StandardColumn.LogEvent); var builder = new LoggerConfiguration() .Destructure.With(policies.ToArray()) .Enrich.FromLogContext() .WriteTo.StacksSqlServer(options.ConnectionString, options.TraceTableName, autoCreateSqlTable: true, columnOptions: columnOptions, locations: locations) .MinimumLevel.Is(options.GetLogLevel()); _logger = builder.CreateLogger(); }
public LocationBatcher(IPInformationProvider provider, SqlServerLoggingOptions options) : base(options.BatchSize, options.Period) { _provider = provider; _options = options; }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerLoggingModule"/> class. /// </summary> /// <param name="options">The options to use.</param> public SqlServerLoggingModule(SqlServerLoggingOptions options) { Argument.NotNull(options, nameof(options)); _options = options; }