Skip to content

Commit

Permalink
logging: limit main log file size to 100mb
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Jul 19, 2024
1 parent 19464ec commit 25cf7fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Dalamud.Injector/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ private static void InitLogging(bool verbose, IEnumerable<string> args)

CullLogFile(logPath, 1 * 1024 * 1024);

const long maxLogSize = 100 * 1024 * 1024; // 100MB
Log.Logger = new LoggerConfiguration()
.WriteTo.Console(standardErrorFromLevel: LogEventLevel.Debug)
.WriteTo.File(logPath, fileSizeLimitBytes: null)
.WriteTo.File(logPath, fileSizeLimitBytes: maxLogSize)
.MinimumLevel.ControlledBy(levelSwitch)
.CreateLogger();

Expand Down
5 changes: 3 additions & 2 deletions Dalamud/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,16 @@ internal static void InitLogging(string baseDirectory, bool logConsole, bool log
.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)));
}
Expand Down

0 comments on commit 25cf7fd

Please sign in to comment.