serilog / serilog-sinks-periodicbatching

Infrastructure for Serilog sinks that process events in batches.
Apache License 2.0
70 stars 29 forks source link

Document how to rework the sink changes for `PeriodicBatchingSink` and `PeriodicBatchingSinkOptions` #88

Closed SeppPenner closed 3 days ago

SeppPenner commented 4 days ago

It would be good to adjust the readme and add a more concrete example on how to use the IBatchedLogEventSink after the changes made in V4 of Serilog.

Old code:

var batchingOptions = new PeriodicBatchingSinkOptions()
{
    BatchSizeLimit = postgresOptions.BatchSizeLimit,
    Period = postgresOptions.Period,
    QueueLimit = postgresOptions.QueueLimit
};

var batchingSink = new PeriodicBatchingSink(new PostgreSqlSink(postgresOptions), batchingOptions);
return sinkConfiguration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);

New code:

var batchingOptions = new BatchingOptions()
{
    BatchSizeLimit = postgresOptions.BatchSizeLimit,
    BufferingTimeLimit = postgresOptions.Period,
    QueueLimit = postgresOptions.QueueLimit
};

return sinkConfiguration.Sink(new PostgreSqlSink(postgresOptions), batchingOptions, restrictedToMinimumLevel, levelSwitch);

E.g. my complete changes for Serilog.Sinks.Postgresql.Alternative: https://github.com/serilog-contrib/Serilog.Sinks.Postgresql.Alternative/commit/dd282cdd01c694ed586052a023e653d11dda62d1.

nblumhardt commented 3 days ago

Thanks for the suggestion! I'll use your example, let me know if you had any other tweaks in mind :-)