Skip to content
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

Serilog output file is being removed by Docker bind mount and never gets recreated until time comes of RollingInterval #331

Closed
aliaiden opened this issue Dec 26, 2024 · 1 comment

Comments

@aliaiden
Copy link

Serilog output file is being removed by Docker bind mount and never gets recreated until time comes of RollingInterval.

Description
I am adding Serilog logging in an existing .NET Core server application.
Serilog output file is being removed by Docker compose up command(docker-compose up -d) when I add logs folder volume bind mount. Removal of file is expected because the mount host folder is empty and Docker syncs both folders and makes changes to the folder contents. After that file removal the log file never gets created until the next time comes of RollingInterval.DAY i.e. 24 hours later.
During the first 24 hours since deployment, server app logs are lost because Serilog is not recreating the removed log file. Even though the methods in the source code are being called i.e Log.Information("Some logging message");

Reproduction Configurations
"Docker" Version="4.29.0"
"Docker Compose" Version="v2.26.1-desktop.1"
".NET Core" Version="8.0"

"Serilog" Version="4.0.0"
"Serilog.AspNetCore" Version="8.0.1"
"Serilog.Formatting.Compact" Version="3.0.0"
"Serilog.Sinks.Http" Version="9.0.0"

Expected behavior
When my docker container is started, the logs folder should not be empty after Log.Information("Some logging message") method is called.
OR when the file is deleted by the Docker volume sync process, then Serilog should recreate output file whenever Log.Information("Some logging message"); is called.

Relevant package, tooling and runtime versions
What Serilog version are you using, on what platform?
"Serilog" Version="4.0.0"
"Serilog.AspNetCore" Version="8.0.1"
"Serilog.Formatting.Compact" Version="3.0.0"
"Serilog.Sinks.Http" Version="9.0.0"

"Docker" Version="4.29.0"
"Docker Compose" Version="v2.26.1-desktop.1"
".NET Core" Version="8.0"

App container was deployed Windows and also on Linux. Got this problem on both deployments.

Additional info
If there is anything I am doing wrong then please guide/correct my implementation.

@nblumhardt
Copy link
Member

Duplicate of #128

@nblumhardt nblumhardt marked this as a duplicate of #128 Dec 29, 2024
@nblumhardt nblumhardt added duplicate and removed bug labels Dec 29, 2024
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