You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
891 B
31 lines
891 B
using Tiobon.Core.Common;
|
|
using Tiobon.Core.Serilog.Sink;
|
|
using Serilog;
|
|
using Serilog.Sinks.PeriodicBatching;
|
|
|
|
namespace Tiobon.Core.Serilog.Configuration;
|
|
|
|
public static class LogBatchingSinkConfiguration
|
|
{
|
|
public static LoggerConfiguration WriteToLogBatching(this LoggerConfiguration loggerConfiguration)
|
|
{
|
|
if (!AppSettings.app("AppSettings", "LogToDb").ObjToBool())
|
|
{
|
|
return loggerConfiguration;
|
|
}
|
|
|
|
var exampleSink = new LogBatchingSink();
|
|
|
|
var batchingOptions = new PeriodicBatchingSinkOptions
|
|
{
|
|
BatchSizeLimit = 500,
|
|
Period = TimeSpan.FromSeconds(1),
|
|
EagerlyEmitFirstEvent = true,
|
|
QueueLimit = 10000
|
|
};
|
|
|
|
var batchingSink = new PeriodicBatchingSink(exampleSink, batchingOptions);
|
|
|
|
return loggerConfiguration.WriteTo.Sink(batchingSink);
|
|
}
|
|
} |