Does it make sense to wrap the SQL Server Serilog sink inside Async?

Viewed 844

I am trying to minimize the performance impact of writing logs to SQL Server from a .NET Core application.

In the past I've wrapped a Serilog File sink inside of an Async sink - and that greatly helped performance.

The SQL Server sink documentation states that it batches log entries periodically and/or when batchPostingLimit has been reached. What I can't find is any information on what happens when it does decide to issue an INSERT command.

Does it happen asynchronously relative to the code that called Logger.Log(...) or not? If not, does it make sense to wrap the SQL Server Serilog sink inside Async?

1 Answers

The SQL Server sink derives from PeriodicBatchingSink, which executes all batched operations asynchronously.

So no, Serilog.Sinks.Async won't improve the performance of the SQL Server sink in its current form.

Related