Serilog.Sinks.PeriodicBatching 5.0.0
Serilog.Sinks.PeriodicBatching

A wrapper for Serilog sinks that asynchronously emits events in batches, useful when logging to a slow and/or remote target.
Important
Serilog 4.x and later versions support batching natively. New projects should use Serilog's IBatchedLogEventSink and
WriteTo.Sink(IBatchedLogEventSink), not this package which is now only maintained for compatibility reasons.
Getting started
Sinks that, for performance reasons, need to emit events in batches, can be implemented using PeriodicBatchingSink
from this package.
First, install the package into your Sink project:
dotnet add package Serilog.Sinks.PeriodicBatching
Then, instead of implementing Serilog's ILogEventSink, implement IBatchedLogEventSink in your sink class:
class ExampleBatchedSink : IBatchedLogEventSink
{
public async Task EmitBatchAsync(IEnumerable<LogEvent> batch)
{
foreach (var logEvent in batch)
Console.WriteLine(logEvent);
}
public Task OnEmptyBatchAsync() { }
}
Finally, in your sink's configuration method, construct a PeriodicBatchingSink that wraps your batched sink:
public static class LoggerSinkExampleConfiguration
{
public static LoggerConfiguration Example(this LoggerSinkConfiguration loggerSinkConfiguration)
{
var exampleSink = new ExampleBatchedSink();
var batchingOptions = new PeriodicBatchingSinkOptions
{
BatchSizeLimit = 100,
Period = TimeSpan.FromSeconds(2),
EagerlyEmitFirstEvent = true,
QueueLimit = 10000
};
var batchingSink = new PeriodicBatchingSink(exampleSink, batchingOptions);
return loggerSinkConfiguration.Sink(batchingSink);
}
}
Showing the top 20 packages that depend on Serilog.Sinks.PeriodicBatching.
| Packages | Downloads |
|---|---|
|
Serilog.Sinks.Seq
A Serilog sink that writes events to Seq using newline-delimited JSON and HTTP/HTTPS.
|
1,575 |
|
Serilog.Sinks.SyslogMessages
Fully-featured Serilog sink that logs events to remote syslog servers using UDP, TCP, and TLS over TCP, and can also use POSIX libc syslog functions to write to the local syslog service on Linux systems. Both RFC3164 and RFC5424 format messages are supported.
|
1,202 |