I use Serilog async logging and while doing performance testing with multiple users we found that serilog is taking all the CPU (up to 100%). ASP.net code creates log file using Serilog Async (log.info, log.warning, log.error) and it has logging on all web pages due to security logging requirements. CPU usage spikes after 2 hours and remains 100% continuously and system is getting major performance hit.
We also tested application without SeriLog enabled, the application does not spike up to 100% CPU usage.
I would really appreciate if I get any help here. I can share code (logger class) I created if needed.
And how the logging is configured:
var logConfig = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Async(logSink =>
{
logSink.File(
logFilePath,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: null,
outputTemplate: OutputTemplate,
hooks: new HeaderWriter(header),
flushToDiskInterval: TimeSpan.FromSeconds(10),
shared: true
);
});
Log.Logger = logConfig.CreateLogger();