-
Notifications
You must be signed in to change notification settings - Fork 61
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
Truncating/Deleting log files while logging application is running #78
Comments
For this purpose you can use rolling file feature, it has several modes so you can choose which one is more suitable exactly for your app.
FileShare.Read allows other processes to open active log file for 'read'; it is a bit unclear how log file can work in FileShare.ReadWrite mode, most likely you'll not able to achieve what you want by opening active log file for 'write' (and do what?..). |
Hi, thanks for your quick answer!
We know about the rolling feature - sorry for this misunderstanding. The use case is not to roll the log based on time or file size, but to truncate it to size 0 on an event manually observed while using the application and running into an error on a live system. for example with this command line
or by some code in our application of course.
Yeah, I know what you mean. But if you know what you are doing an opt-in configuration would enable it if you need it. To be honest, I have seen many loggers not restricting concurrent write or delete operations (or probably just don't keep the file open while not writing into it) without any problems. It would help devops to do service for their customers ;-) |
If you need an option that changes However, I want to ensure that this option really is needed and you can achieve what you need - could you confirm that? You can simply change it here https://github.com/nreco/logging/blob/master/src/NReco.Logging.File/FileLoggerProvider.cs#L220 and try your build to check that. |
good idea, we will check that and give you some feedback |
Hi,
within our windows application there is a debug logging mode which generates quite a lot of log output.
If this mode is active it would be nice to occasionally truncate or delete the log file(s) without stopping and restarting application.
This would be very helpful when "debugging" the application on systems of the application user (without development environment).
Would it be possible to implement a configuration key like "non-exclusive" for the file logger, as the FileShareMode is currently hard coded as FileShare.Read without sharing write and delete operations.
For compatibility reason this option could be defaulting to the current behavior, of course.
The text was updated successfully, but these errors were encountered: