logging: limit main log file size to 100mb

This commit is contained in:
goat 2024-07-19 18:50:15 +02:00
parent 19464ec080
commit 25cf7fde10
2 changed files with 5 additions and 3 deletions

View file

@ -107,15 +107,16 @@ public sealed class EntryPoint
.WriteTo.Sink(SerilogEventSink.Instance)
.MinimumLevel.ControlledBy(LogLevelSwitch);
const long maxLogSize = 100 * 1024 * 1024; // 100MB
if (logSynchronously)
{
config = config.WriteTo.File(logPath.FullName, fileSizeLimitBytes: null);
config = config.WriteTo.File(logPath.FullName, fileSizeLimitBytes: maxLogSize);
}
else
{
config = config.WriteTo.Async(a => a.File(
logPath.FullName,
fileSizeLimitBytes: null,
fileSizeLimitBytes: maxLogSize,
buffered: false,
flushToDiskInterval: TimeSpan.FromSeconds(1)));
}