Serilog.Sinks.PeriodicBatching 5.0.0-dev-00855
Serilog.Sinks.PeriodicBatching
A wrapper for Serilog sinks that asynchronously emits events in batches, useful when logging to a slow and/or remote target.
[!IMPORTANT] Serilog 4.x and later versions support batching natively. New projects should use Serilog's
IBatchedLogEventSink
andWriteTo.Sink(IBatchedLogEventSink)
, not this package which is now only maintained for compatibility reasons.
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.
|
144 |
Serilog.Sinks.AwsCloudWatch
A Serilog sink that logs to AWS CloudWatch
|
54 |
Serilog.Sinks.Elasticsearch
Package Description
|
45 |
Serilog.Sinks.AwsCloudWatch
A Serilog sink that logs to AWS CloudWatch
|
43 |
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
|
40 |
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
|
39 |
Serilog.Sinks.Elasticsearch
Package Description
|
37 |
Serilog.Sinks.Elasticsearch
Package Description
|
36 |
Serilog.Sinks.Elasticsearch
Package Description
|
35 |
Serilog.Sinks.Elasticsearch
Package Description
|
33 |
Serilog.Sinks.Elasticsearch
Serilog sink for Elasticsearch
|
32 |
Serilog.Sinks.Elasticsearch
Serilog.Sinks.Elasticsearch
|
31 |
Serilog.Sinks.Elasticsearch
Package Description
|
29 |
Serilog.Sinks.Elasticsearch
Package Description
|
28 |
Serilog.Sinks.AwsCloudWatch
A Serilog sink that logs to AWS CloudWatch
|
28 |
Serilog.Sinks.Elasticsearch
The perfect way for .NET apps to write structured log events to Elasticsearch 2.x.
|
27 |
Version | Downloads | Last updated |
---|---|---|
5.0.1-dev-00860 | 3 | 07/06/2024 |
5.0.0 | 4 | 06/07/2024 |
5.0.0-dev-00855 | 2 | 06/08/2024 |
4.1.2-dev-00851 | 3 | 06/01/2024 |
4.1.1 | 22 | 05/31/2024 |
4.1.1-dev-00845 | 3 | 05/24/2024 |
4.1.0 | 20 | 05/15/2024 |
4.1.0-dev-00840 | 6 | 05/16/2024 |
4.0.2-dev-00838 | 4 | 05/16/2024 |
4.0.1 | 13 | 03/18/2024 |
4.0.1-dev-00832 | 3 | 03/19/2024 |
4.0.0 | 11 | 03/18/2024 |
4.0.0-dev-00824 | 10 | 02/09/2024 |
4.0.0-dev-00821 | 8 | 02/09/2024 |
3.1.1-dev-00804 | 17 | 06/02/2023 |
3.1.1-dev-00801 | 7 | 08/30/2023 |
3.1.0 | 11 | 08/24/2023 |
3.1.0-dev-00796 | 43 | 06/01/2023 |
3.0.0 | 25 | 08/24/2023 |
3.0.0-dev-00792 | 8 | 08/30/2023 |
2.3.1 | 13 | 08/31/2023 |
2.3.1-dev-00785 | 8 | 08/26/2023 |
2.3.1-dev-00780 | 8 | 08/30/2023 |
2.3.1-dev-00776 | 11 | 09/09/2023 |
2.3.1-dev-00774 | 7 | 08/27/2023 |
2.3.0 | 13 | 08/25/2023 |
2.3.0-dev-00765 | 4 | 08/31/2023 |
2.3.0-dev-00762 | 15 | 08/25/2023 |
2.3.0-dev-00760 | 4 | 08/30/2023 |
2.2.1-dev-00758 | 6 | 05/18/2023 |
2.2.1-dev-00755 | 6 | 08/26/2023 |
2.2.0 | 14 | 08/28/2023 |
2.2.0-dev-00748 | 15 | 08/25/2023 |
2.2.0-dev-00740 | 13 | 08/30/2023 |
2.1.1 | 70 | 07/01/2020 |
2.1.1-dev-00732 | 6 | 08/26/2023 |
2.1.1-dev-00729 | 6 | 08/30/2023 |
2.1.1-dev-00725 | 3 | 02/15/2024 |
2.1.0 | 136 | 05/07/2021 |
2.1.0-dev-00720 | 12 | 08/27/2023 |
2.0.2-dev-00719 | 37 | 05/17/2023 |
2.0.1 | 6 | 08/29/2023 |
2.0.1-dev-00714 | 9 | 08/30/2023 |
2.0.0 | 36 | 11/25/2019 |
2.0.0-rc-707 | 10 | 08/30/2023 |
2.0.0-rc-705 | 30 | 08/25/2023 |
2.0.0-beta-702 | 16 | 08/29/2023 |
2.0.0-beta-700 | 9 | 08/27/2023 |
2.0.0-beta-519 | 7 | 08/27/2023 |
2.0.0-beta-516 | 5 | 08/31/2023 |
2.0.0-beta-513 | 13 | 08/26/2023 |
2.0.0-beta-511 | 14 | 08/28/2023 |
2.0.0-beta-509 | 18 | 08/25/2023 |
2.0.0-beta-507 | 9 | 05/18/2023 |
2.0.0-beta-505 | 7 | 09/01/2023 |
2.0.0-beta-502 | 4 | 08/27/2023 |
2.0.0-beta-499 | 5 | 08/29/2023 |
2.0.0-beta-495 | 7 | 08/26/2023 |
2.0.0-beta-494 | 8 | 12/07/2023 |
2.0.0-beta-493 | 5 | 08/28/2023 |
2.0.0-beta-487 | 13 | 08/25/2023 |
2.0.0-beta-486 | 5 | 05/17/2023 |
2.0.0-beta-479 | 7 | 08/31/2023 |
2.0.0-beta-478 | 13 | 08/30/2023 |
2.0.0-beta-465 | 7 | 08/26/2023 |