I'm using Serilog on a .NET Core Service Fabric application.
We noticed performance issues and after investigation it turns out that Serilog is the culprit.
We log ~2,000 Debug messages and it takes 10+ seconds.
This is even with only the Console sink configured and set to filter on Information log level only (so not displaying any Debug messages).
Setting the MinimumLevel to Information makes the same code run <1 second (even with sinks configured).
Our project uses:
- netcoreapp2.0
- Serilog NuGet package 2.8.0 (latest)
Is this the kind of performance that is expected from Serilog?
EDIT: I noticed the same behaviour on another (much) smaller project. That allowed me to isolate the issue: I had a custom enricher that was retrieving the ProcessId. Calling Process.GetCurrentProcess() is incredibly expensive. Doing that for every logging call was what was killing the performance. I stored the process Id in an instance field and the performance soared.
Log.IsEnabledto make your log statements conditional. I'm pretty sure select is not broken wrt serilog - I and many others have lots of debug logging with no such impacts. Having said all this, if you are sending a lot of messages via the console sink and they're not being filtered out, the writing, if not wrapped in Serilog.Sinks.Async will affect the perf of your mainline processing (but you seem to be ruling that out) - Ruben Bartelink