Skip to content

When log file is recreated externally, serilog stops logging infinitely until application restarts. #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
starkapandan opened this issue Feb 23, 2025 · 1 comment

Comments

@starkapandan
Copy link

Description
Bug, asp net core, while app is running if the log file is recreated say from external logrotate built into linux or manually by hand the log is recreated with same permission, serilog completely stops logging infinitely until full restart of application.

Reproduction
start any asp.net core application, start logging, perform a logrotate on the existing log file, serilog will no longer log anything to the new file until the full application is restarted:

pretty much only this code wise
builder.Host.UseSerilog((context, loggerConfiguration) => { loggerConfiguration .ReadFrom.Configuration(context.Configuration) });

and json wise pretty basic aswell:
"Serilog": { "Using": [ "Serilog.Sinks.File" ], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft.AspNetCore": "Warning" } }, "WriteTo": [ { "Name": "File", "Args": { "path": "/var/log/example.log", "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog" } } ] },

Expected behavior
after a logrotate has been performed, serilog should be able to keep logging to the new file(eg its same file but deleted then created again), it shouln't "stick" to the non existing file reference

Relevant package, tooling and runtime versions
ubuntu 24.04 with asp.net core 9

@nblumhardt
Copy link
Member

Duplicate of #96

@nblumhardt nblumhardt marked this as a duplicate of #96 Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants