Lossy logging in log4net is great to get the details of events leading to an error with minimal performance-loss. However it would often be interesting to also log a few messages after the error to verify that the system handled it as planned. How can it be done?
I would write a custom version of the BufferingForwardAppender, which would log a configurable number of message after an error. Basically you turn off "being lossy" after an error for a while and forward all messages directly.
Note: Make sure that the appender flushes the messages immediately when an error is logged because you cannot be sure that there will be other messages after the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With