Serilog.Sinks.PeriodicBatching 4.0.1-dev-00832

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.
34
Serilog.Sinks.Email
Send Serilog events as SMTP email using MailKit.
34
Serilog.Sinks.Email
Send Serilog events as SMTP email using MailKit.
41
Serilog.Sinks.Email
The file sink for Serilog
28
Serilog.Sinks.Email
The file sink for Serilog
35
Serilog.Sinks.Seq
A Serilog sink that writes events to Seq using newline-delimited JSON and HTTP/HTTPS.
28
Serilog.Sinks.Seq
A Serilog sink that writes events to Seq using newline-delimited JSON and HTTP/HTTPS.
36
Serilog.Sinks.Seq
Serilog sink that writes to the Seq event server over HTTP/S.
28
Serilog.Sinks.Seq
Serilog sink that writes to the Seq event server over HTTP/S.
31
Serilog.Sinks.Seq
Serilog sink that writes to the Seq event server over HTTP/S.
32
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
28
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
31
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
34
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
59
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
96
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
178
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
336
Serilog.Sinks.Seq
Serilog sink that writes to the Seq log server over HTTP/HTTPS.
478

.NET Framework 4.6.2

.NET 6.0

.NET Standard 2.0

Version Downloads Last updated
5.0.1-dev-00860 30 07/06/2024
5.0.0 26 06/06/2024
5.0.0-dev-00855 23 06/07/2024
4.1.2-dev-00851 27 06/04/2024
4.1.1 26 05/29/2024
4.1.1-dev-00845 25 05/27/2024
4.1.0 32 05/12/2024
4.1.0-dev-00840 20 05/12/2024
4.0.2-dev-00838 24 05/12/2024
4.0.1 30 03/15/2024
4.0.1-dev-00832 25 03/15/2024
4.0.0 30 03/13/2024
4.0.0-dev-00824 33 02/08/2024
4.0.0-dev-00821 36 02/08/2024
3.1.1-dev-00804 21 02/08/2024
3.1.1-dev-00801 31 02/08/2024
3.1.0 156 10/10/2022
3.1.0-dev-00796 40 02/08/2024
3.0.0 56 09/20/2022
3.0.0-dev-00792 24 02/08/2024
2.3.1 81 04/15/2022
2.3.1-dev-00785 26 02/08/2024
2.3.1-dev-00780 28 02/08/2024
2.3.1-dev-00776 26 02/08/2024
2.3.1-dev-00774 29 02/08/2024
2.3.0 503 02/26/2021
2.3.0-dev-00765 25 02/08/2024
2.3.0-dev-00762 31 02/08/2024
2.3.0-dev-00760 27 02/08/2024
2.2.1-dev-00758 27 02/08/2024
2.2.1-dev-00755 23 02/08/2024
2.2.0 32 02/10/2020
2.2.0-dev-00748 28 02/08/2024
2.2.0-dev-00740 29 02/08/2024
2.1.1 29 07/04/2020
2.1.1-dev-00732 30 02/08/2024
2.1.1-dev-00729 25 02/08/2024
2.1.1-dev-00725 37 02/08/2024
2.1.0 31 02/08/2024
2.1.0-dev-00720 27 02/08/2024
2.0.2-dev-00719 26 02/08/2024
2.0.1 30 02/08/2024
2.0.1-dev-00714 26 02/08/2024
2.0.0 45 02/08/2024
2.0.0-rc-707 30 02/08/2024
2.0.0-rc-705 27 02/08/2024
2.0.0-beta-702 26 02/08/2024
2.0.0-beta-700 28 02/08/2024
2.0.0-beta-519 25 02/08/2024
2.0.0-beta-516 27 02/08/2024
2.0.0-beta-513 31 02/08/2024
2.0.0-beta-511 27 02/08/2024
2.0.0-beta-509 25 02/08/2024
2.0.0-beta-507 32 02/08/2024
2.0.0-beta-505 26 02/08/2024
2.0.0-beta-502 24 02/08/2024
2.0.0-beta-499 29 02/08/2024
2.0.0-beta-495 22 02/08/2024
2.0.0-beta-494 22 02/08/2024
2.0.0-beta-493 29 02/08/2024
2.0.0-beta-487 31 02/08/2024
2.0.0-beta-486 32 02/08/2024
2.0.0-beta-479 33 02/08/2024
2.0.0-beta-478 33 02/08/2024
2.0.0-beta-465 26 02/08/2024