Serilog.Sinks.PeriodicBatching 4.0.0-dev-00824

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
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
27
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
27
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
28
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
31
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
32
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
33
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
35
Serilog.Sinks.Http
A Serilog sink sending log events over HTTP.
71
Serilog.Sinks.Http
Serilog event sink that sends HTTP POST requests over the network.
27
Serilog.Sinks.Http
Serilog event sink that sends HTTP POST requests over the network.
29
Serilog.Sinks.Http
Serilog event sink that sends HTTP POST requests over the network.
31
Serilog.Sinks.Http
Serilog event sink that sends HTTP POST requests over the network.
32
Serilog.Sinks.PostgreSQL
Serilog sink for writing to PostgreSQL table
29
Serilog.Sinks.PostgreSQL
Serilog sink for writing to PostgreSQL table
31
Serilog.Sinks.PostgreSQL
Serilog sink for writing to PostgreSQL table
182

.NET Framework 4.6.2

.NET 6.0

.NET Standard 2.0

Version Downloads Last updated
5.0.1-dev-00860 24 07/18/2024
5.0.0 32 07/22/2024
5.0.0-dev-00855 25 07/23/2024
4.1.2-dev-00851 23 07/23/2024
4.1.1 31 07/23/2024
4.1.1-dev-00845 21 07/23/2024
4.1.0 27 07/23/2024
4.1.0-dev-00840 28 07/23/2024
4.0.2-dev-00838 22 07/23/2024
4.0.1 32 07/23/2024
4.0.1-dev-00832 22 07/23/2024
4.0.0 33 07/23/2024
4.0.0-dev-00824 22 07/23/2024
4.0.0-dev-00821 21 07/23/2024
3.1.1-dev-00804 26 07/21/2024
3.1.1-dev-00801 22 07/23/2024
3.1.0 27 07/23/2024
3.1.0-dev-00796 25 07/23/2024
3.0.0 33 07/23/2024
3.0.0-dev-00792 39 07/23/2024
2.3.1 22 07/23/2024
2.3.1-dev-00785 22 07/23/2024
2.3.1-dev-00780 35 07/23/2024
2.3.1-dev-00776 21 07/23/2024
2.3.1-dev-00774 37 07/23/2024
2.3.0 108 02/04/2024
2.3.0-dev-00765 30 07/23/2024
2.3.0-dev-00762 19 07/23/2024
2.3.0-dev-00760 27 07/23/2024
2.2.1-dev-00758 28 07/23/2024
2.2.1-dev-00755 27 07/23/2024
2.2.0 30 07/23/2024
2.2.0-dev-00748 21 07/23/2024
2.2.0-dev-00740 30 07/22/2024
2.1.1 30 07/21/2024
2.1.1-dev-00732 27 07/23/2024
2.1.1-dev-00729 29 07/23/2024
2.1.1-dev-00725 23 07/23/2024
2.1.0 35 07/23/2024
2.1.0-dev-00720 19 07/23/2024
2.0.2-dev-00719 26 07/23/2024
2.0.1 27 07/23/2024
2.0.1-dev-00714 22 07/23/2024
2.0.0 20 07/23/2024
2.0.0-rc-707 30 07/23/2024
2.0.0-rc-705 25 07/18/2024
2.0.0-beta-702 24 07/18/2024
2.0.0-beta-700 27 07/18/2024
2.0.0-beta-519 30 07/18/2024
2.0.0-beta-516 30 07/18/2024
2.0.0-beta-513 17 07/18/2024
2.0.0-beta-511 20 07/18/2024
2.0.0-beta-509 29 07/18/2024
2.0.0-beta-507 25 07/18/2024
2.0.0-beta-505 31 07/18/2024
2.0.0-beta-502 27 07/18/2024
2.0.0-beta-499 31 07/18/2024
2.0.0-beta-495 20 07/18/2024
2.0.0-beta-494 25 07/18/2024
2.0.0-beta-493 24 07/18/2024
2.0.0-beta-487 27 07/18/2024
2.0.0-beta-486 30 07/18/2024
2.0.0-beta-479 23 07/18/2024
2.0.0-beta-478 25 07/18/2024
2.0.0-beta-465 25 07/18/2024