Serilog.Sinks.PeriodicBatching 4.1.2-dev-00851

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.AmazonKinesis
Serilog event sink that writes to Amazon Kinesis.
157
Serilog.Sinks.AwsCloudWatch
A Serilog sink that logs to AWS CloudWatch
64
Serilog.Sinks.Elasticsearch
Package Description
54
Serilog.Sinks.AwsCloudWatch
A Serilog sink that logs to AWS CloudWatch
52
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
49
Serilog.Sinks.Elasticsearch
Package Description
47
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
45
Serilog.Sinks.Elasticsearch
Package Description
44
Serilog.Sinks.Elasticsearch
Package Description
43
Serilog.Sinks.Elasticsearch
Package Description
42
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
41
Serilog.Sinks.Elasticsearch
Serilog.Sinks.Elasticsearch
41
Serilog.Sinks.Elasticsearch
Package Description
40
Serilog.Sinks.AwsCloudWatch
A Serilog sink that logs to AWS CloudWatch
40
Serilog.Sinks.Elasticsearch
Package Description
39
Serilog.Sinks.MSSqlServerCore
DEPRECATED - Please use official Serilog sink for MSSqlServer as it now fully supports .NET Standard
38
Serilog.Sinks.AwsCloudWatch
A Serilog sink that logs to AWS CloudWatch
38

.NET Framework 4.6.2

.NET 6.0

.NET Standard 2.0

Version Downloads Last updated
5.0.1-dev-00860 18 07/06/2024
5.0.0 11 06/07/2024
5.0.0-dev-00855 13 06/08/2024
4.1.2-dev-00851 14 06/01/2024
4.1.1 31 05/31/2024
4.1.1-dev-00845 16 05/24/2024
4.1.0 31 05/15/2024
4.1.0-dev-00840 19 05/16/2024
4.0.2-dev-00838 17 05/16/2024
4.0.1 23 03/18/2024
4.0.1-dev-00832 16 03/19/2024
4.0.0 19 03/18/2024
4.0.0-dev-00824 21 02/09/2024
4.0.0-dev-00821 19 02/09/2024
3.1.1-dev-00804 29 06/02/2023
3.1.1-dev-00801 16 08/30/2023
3.1.0 18 08/24/2023
3.1.0-dev-00796 60 06/01/2023
3.0.0 36 08/24/2023
3.0.0-dev-00792 18 08/30/2023
2.3.1 22 08/31/2023
2.3.1-dev-00785 19 08/26/2023
2.3.1-dev-00780 19 08/30/2023
2.3.1-dev-00776 19 09/09/2023
2.3.1-dev-00774 18 08/27/2023
2.3.0 21 08/25/2023
2.3.0-dev-00765 15 08/31/2023
2.3.0-dev-00762 27 08/25/2023
2.3.0-dev-00760 15 08/30/2023
2.2.1-dev-00758 16 05/18/2023
2.2.1-dev-00755 16 08/26/2023
2.2.0 21 08/28/2023
2.2.0-dev-00748 25 08/25/2023
2.2.0-dev-00740 26 08/30/2023
2.1.1 79 07/01/2020
2.1.1-dev-00732 15 08/26/2023
2.1.1-dev-00729 17 08/30/2023
2.1.1-dev-00725 16 02/15/2024
2.1.0 144 05/07/2021
2.1.0-dev-00720 21 08/27/2023
2.0.2-dev-00719 50 05/17/2023
2.0.1 14 08/29/2023
2.0.1-dev-00714 19 08/30/2023
2.0.0 43 11/25/2019
2.0.0-rc-707 19 08/30/2023
2.0.0-rc-705 39 08/25/2023
2.0.0-beta-702 28 08/29/2023
2.0.0-beta-700 21 08/27/2023
2.0.0-beta-519 19 08/27/2023
2.0.0-beta-516 17 08/31/2023
2.0.0-beta-513 27 08/26/2023
2.0.0-beta-511 23 08/28/2023
2.0.0-beta-509 29 08/25/2023
2.0.0-beta-507 21 05/18/2023
2.0.0-beta-505 17 09/01/2023
2.0.0-beta-502 17 08/27/2023
2.0.0-beta-499 16 08/29/2023
2.0.0-beta-495 17 08/26/2023
2.0.0-beta-494 21 12/07/2023
2.0.0-beta-493 15 08/28/2023
2.0.0-beta-487 24 08/25/2023
2.0.0-beta-486 18 05/17/2023
2.0.0-beta-479 20 08/31/2023
2.0.0-beta-478 24 08/30/2023
2.0.0-beta-465 18 08/26/2023