Ole Albers
Ole Albers

Reputation: 9285

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?

Upvotes: 10

Views: 468

Answers (1)

Stefan Egli
Stefan Egli

Reputation: 17018

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

Upvotes: 7

Related Questions