-
Notifications
You must be signed in to change notification settings - Fork 130
Always flush sink on Fatal events #356
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
base: dev
Are you sure you want to change the base?
Conversation
|
Thinking about the scenario you describe, it sounds like that one in particular would be solved by calling |
|
Thanks for taking a look! You’re right that the filestream should also be flushed during disposal. However, in most cases, flushing the TextWriter (as is currently done) seems to be sufficient and flushes to the file as well. That’s what I’m currently doing by calling I’m not sure how you feel about breaking changes, but I think it could be justified to always flush for Fatal events, even without an additional API for configuring this. Alternatively, I’d be happy if there was a way to access the |
|
Thanks for the analysis and suggestions, much appreciated. Having fatal errors fully flushed to disk, even when buffering is disabled, seems like it would be acceptable and a decent improvement, given that there's no plan to expose flushing via another mechanism. E.g. thinking it would be: if (logEvent.Level == LogEventLevel.Fatal)
FlushToDisk();
else if (!_buffered)
_output.Flush();It does open up the possibility of causing a performance drain if a large number of It'd be worth bumping the major version and documenting this in the |
|
Thanks @nblumhardt, I applied your suggestions! Let me know if anything else is required. |
Implements #247
Always flush the
FileSinkwhen aLogLevelEvent.Fatalevent is emitted. This is a breaking change in behavior.A common use case is having a flush interval set, but still wanting to force flush
Fatalevents to the file before the process terminates. Previously, these log events would have been lost.Add the option to provide a minimum log level usingflushAtMinimumLevelfor which the sink should flush to disk immediately.To retain backwards compatibility, the default value is
LevelAlias.Off.