简体   繁体   English

缓冲log4net Debug-Messages以显示错误?

[英]Buffering log4net Debug-Messages to display them on error?

Most of us start using logging with the output of DEBUG messages. 我们大多数人开始使用带有DEBUG消息输出的日志记录。 When the project runs for a while usually we reduce the output to INFO or even WARN levels. 当项目运行一段时间时,我们通常会将输出减少到INFO甚至WARN级别。

But when an error occurs I just miss that DEBUG-Messages before the error came up. 但是当发生错误时,我会在错误出现之前错过DEBUG-Messages。 So this is what I want: 所以这就是我想要的:

Just log from INFO or above. 只需从INFO或以上登录即可。 But when an error occurs I also want the DEBUG-messages that appeared before. 但是当发生错误时,我也想要之前出现的DEBUG消息。 Is there an appender or code snippet to achieve that? 是否有一个appender或代码片段来实现这一目标?

Log4net has an appender for just this purpose: ´BufferingForwardingAppender´. Log4net就是为了这个目的而提供的一个追随者:'BuseringForwardingAppender'。

This tutorial contains everything you need: http://www.beefycode.com/post/Log4Net-Tutorial-pt-8-Lossy-Logging.aspx 本教程包含您需要的一切: http//www.beefycode.com/post/Log4Net-Tutorial-pt-8-Lossy-Logging.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM