If you ever had to maintain an application, you know that good logs are your best friend. That is one of the reasons why I’m a big fan of Serilog, a structured logging framework for .NET.
And if you ask me how much logging do we need, I would answer that you can not have too much log data. Of course all this log data introduces its own challenges, like how can you search fast through all these logs but also the impact it has on the performance of your application.
If you start writing thousands of messages a second to the Console, you’ll see your application slowing down.
To mitigate this problem, most Serilog sinks write messages by default in asynchronous batches to reduce application latency and improve network performance.
Unfortunately there are few sinks that don’t do this by default, by example the Console sink. For these cases, you can use Serilog.Sinks.Async. It provides an async wrapper WriteTo.Async()
that moves logging onto a worker thread, so that application code can continue executing while file writes etc. proceed in the background.