Serilog.Sinks.PeriodicBatching 4.1.0-dev-00840

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
Microsoft.Extensions.Logging.AzureAppServices
Diagnostics logger for Azure WebApps
17
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
16
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
17
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
18
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
24
Serilog.Sinks.Elasticsearch
Package Description
8
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
9
Serilog.Sinks.Elasticsearch
Serilog.Sinks.Elasticsearch
8
Serilog.Sinks.Seq
Serilog sink that writes to the Seq event server over HTTP/S.
8
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
8
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/S.
8

.NET Framework 4.6.2

.NET 6.0

.NET Standard 2.0

Version Downloads Last updated
5.0.1-dev-00860 18 12.02.2025
5.0.0 19 16.02.2025
5.0.0-dev-00855 17 03.02.2025
4.1.2-dev-00851 19 11.02.2025
4.1.1 17 20.02.2025
4.1.1-dev-00845 17 13.02.2025
4.1.0 17 19.02.2025
4.1.0-dev-00840 18 16.02.2025
4.0.2-dev-00838 17 16.02.2025
4.0.1 18 16.02.2025
4.0.1-dev-00832 19 19.02.2025
4.0.0 18 19.02.2025
4.0.0-dev-00824 18 16.02.2025
4.0.0-dev-00821 18 16.02.2025
3.1.1-dev-00804 18 09.03.2025
3.1.1-dev-00801 16 13.02.2025
3.1.0 20 19.02.2025
3.1.0-dev-00796 18 16.02.2025
3.0.0 21 20.02.2025
3.0.0-dev-00792 18 08.02.2025
2.3.1 18 16.02.2025
2.3.1-dev-00785 19 16.02.2025
2.3.1-dev-00780 20 15.02.2025
2.3.1-dev-00776 17 15.02.2025
2.3.1-dev-00774 17 16.02.2025
2.3.0 18 16.02.2025
2.3.0-dev-00765 17 16.02.2025
2.3.0-dev-00762 18 16.02.2025
2.3.0-dev-00760 21 15.02.2025
2.2.1-dev-00758 17 16.02.2025
2.2.1-dev-00755 18 16.02.2025
2.2.0 21 19.02.2025
2.2.0-dev-00748 21 25.01.2025
2.2.0-dev-00740 17 16.02.2025
2.1.1 18 16.02.2025
2.1.1-dev-00732 17 15.02.2025
2.1.1-dev-00729 17 08.02.2025
2.1.1-dev-00725 17 16.02.2025
2.1.0 19 16.02.2025
2.1.0-dev-00720 17 16.02.2025
2.0.2-dev-00719 20 16.02.2025
2.0.1 20 16.02.2025
2.0.1-dev-00714 18 16.02.2025
2.0.0 21 16.02.2025
2.0.0-rc-707 15 16.02.2025
2.0.0-rc-705 17 16.02.2025
2.0.0-beta-702 15 16.02.2025
2.0.0-beta-700 16 16.02.2025
2.0.0-beta-519 14 16.02.2025
2.0.0-beta-516 18 16.02.2025
2.0.0-beta-513 15 16.02.2025
2.0.0-beta-511 17 16.02.2025
2.0.0-beta-509 15 16.02.2025
2.0.0-beta-507 15 16.02.2025
2.0.0-beta-505 15 16.02.2025
2.0.0-beta-502 14 16.02.2025
2.0.0-beta-499 16 16.02.2025
2.0.0-beta-495 15 15.02.2025
2.0.0-beta-494 15 16.02.2025
2.0.0-beta-493 15 16.02.2025
2.0.0-beta-487 15 16.02.2025
2.0.0-beta-486 14 06.02.2025
2.0.0-beta-479 16 16.02.2025
2.0.0-beta-478 14 18.02.2025
2.0.0-beta-465 15 16.02.2025