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

Add setting to delete existing file on startup #328

Open
ramtechjoe opened this issue Nov 21, 2024 · 1 comment
Open

Add setting to delete existing file on startup #328

ramtechjoe opened this issue Nov 21, 2024 · 1 comment

Comments

@ramtechjoe
Copy link

Is your feature request related to a problem? Please describe.
It would be very helpful to have a single log file for each time an application runs, and to also be able to archive logs from the previous run.

Describe the solution you'd like
A setting could be added to the constructor such as archiveOldFileOnStartup. If set to true the Serilog would delete the current log file. This would trigger OnFileDeleting of any FileLifeCycleHooks

Describe alternatives you've considered
Currently I am using RollingInterval.Hour and retainedFileCountLimit = 1. In combination with a FileLifecycleHooks that will move the File to an archive folder

Additional context
An issue I see is that currently OnFileDeleting seems to be called after the new file is created. This would not work for the desired outcome. Because you would want the old file deleted prior to creating a new file with the same name.

@nblumhardt
Copy link
Member

Thanks for your message. We're not planning to add new rolling policies to this sink at the present time, but #243 (comment) may be what you're after. HTH!

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