Skip to content

nblumhardt/serilog-sinks-async

 
 

Repository files navigation

Serilog.Sinks.Async Build status NuGet

Use this buffered, async, delegating, sink to reduce the time it takes for your app to write your log events to your sinks. This sink can work with any ILogEventSink you use.

Especially suited to non-batching sinks that are either slow to write or have I/O bottlenecks (like http, databases, file writes etc.).

This sink uses a separate worker thread to write to your sink, freeing up the calling thread to run in your app without having to wait.

Install from NuGet:

Install-Package Serilog.Sinks.Async -Pre

Add this sink to your pipeline:

Log.Logger = new LoggerConfiguration()
    .WriteTo.Async(x => x.YourSink())
    // Other logger configuration
    .CreateLogger()

Now YourSink will write messages using a worker thread while your applicatoin thread gets on with more important stuff.

The default memory buffer feeding the worker thread is capped to 10,000 items, after which arriving events will be dropped. To increase or decrease this limit, specify it when configuring the async sink.

Log.Logger = new LoggerConfiguration()
    .WriteTo.Async(x => x.YourSink(), 500) // Max number of events to buffer in memory
    // Other logger configurationg
    .CreateLogger()

About this sink

This sink was created following this conversation thread: serilog/serilog#809

About

An Async Serilog sink

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 93.6%
  • PowerShell 6.4%