Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buffering log4net Debug-Messages to display them on error?

Most of us start using logging with the output of DEBUG messages. When the project runs for a while usually we reduce the output to INFO or even WARN levels.

But when an error occurs I just miss that DEBUG-Messages before the error came up. So this is what I want:

Just log from INFO or above. But when an error occurs I also want the DEBUG-messages that appeared before. Is there an appender or code snippet to achieve that?

like image 582
Ole Albers Avatar asked Feb 16 '12 18:02

Ole Albers


Video Answer


1 Answers

Log4net has an appender for just this purpose: ´BufferingForwardingAppender´.

This tutorial contains everything you need: http://www.beefycode.com/post/Log4Net-Tutorial-pt-8-Lossy-Logging.aspx

like image 110
Stefan Egli Avatar answered Oct 06 '22 22:10

Stefan Egli