Serilog.Sinks.PeriodicBatching 4.1.0

Serilog.Sinks.PeriodicBatching Build status NuGet Version

A wrapper for Serilog sinks that asynchronously emits events in batches, useful when logging to a slow and/or remote target.

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.Http
A Serilog sink sending log events over HTTP.
16
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
16
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
15
Serilog.Sinks.Http
Serilog event sink that sends HTTP POST requests over the network.
15
Serilog.Sinks.Slack
Serilog sink for Slack
14
Serilog.Sinks.Seq
A Serilog sink that writes events to Seq using newline-delimited JSON and HTTP/HTTPS.
14
Microsoft.Extensions.Logging.AzureAppServices
Diagnostics logger for Azure WebApps
14
Serilog.Sinks.Slack
Serilog.Sinks.Slack
14
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
14
Serilog.Sinks.Http
Serilog event sink that sends HTTP POST requests over the network.
14

.NET Framework 4.6.2

.NET 6.0

.NET Standard 2.0

Version Downloads Last updated
5.0.1-dev-00860 15 03/06/2025
5.0.0-dev-00855 13 03/06/2025
4.1.2-dev-00851 13 03/06/2025
4.1.0 13 03/06/2025
4.0.2-dev-00838 13 03/06/2025
4.0.1 13 03/09/2025
4.0.1-dev-00832 13 03/06/2025
4.0.0 15 08/02/2024
4.0.0-dev-00824 13 03/09/2025
4.0.0-dev-00821 13 03/06/2025
3.1.1-dev-00804 13 03/06/2025
3.1.1-dev-00801 12 03/09/2025
3.1.0 13 03/06/2025
3.1.0-dev-00796 13 03/06/2025
3.0.0 13 03/06/2025
3.0.0-dev-00792 13 03/06/2025
2.3.1 13 06/13/2023
2.3.1-dev-00785 12 03/06/2025
2.3.1-dev-00774 13 03/06/2025
2.3.0-dev-00765 13 03/06/2025
2.3.0-dev-00760 13 03/06/2025
2.2.0 14 03/12/2025
2.2.0-dev-00748 13 03/06/2025
2.1.1 14 06/26/2023
2.1.1-dev-00732 13 03/09/2025
2.1.1-dev-00729 13 03/06/2025
2.1.1-dev-00725 13 03/09/2025
2.1.0-dev-00720 13 03/06/2025
2.0.2-dev-00719 13 03/06/2025
2.0.1 13 03/06/2025
2.0.1-dev-00714 13 03/09/2025
2.0.0 13 03/09/2025
2.0.0-rc-707 13 03/06/2025
2.0.0-rc-705 13 03/06/2025
2.0.0-beta-702 13 03/09/2025
2.0.0-beta-519 13 03/06/2025
2.0.0-beta-516 13 03/06/2025
2.0.0-beta-513 14 03/06/2025
2.0.0-beta-509 13 03/06/2025
2.0.0-beta-507 13 03/09/2025
2.0.0-beta-502 14 03/09/2025
2.0.0-beta-495 13 03/09/2025
2.0.0-beta-494 16 03/12/2025
2.0.0-beta-493 13 03/09/2025
2.0.0-beta-479 13 03/06/2025
2.0.0-beta-478 14 03/06/2025