Log4net-禁止显示"exception"从附加到自定义"PatternLayout" [英] Log4net - Suppress "exception" from being appended to custom "PatternLayout"

查看:205
本文介绍了Log4net-禁止显示"exception"从附加到自定义"PatternLayout"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用自定义"PatternLayout"时,log4net会将"exception"信息(如果存在)附加到每个日志条目.我试图控制消息和堆栈跟踪信息的输出,并希望抑制"此信息.我到处搜寻,但找不到解决方法.有什么想法吗?

When using a custom "PatternLayout", log4net is appending the "exception" information (when present) to every log entry. I am trying to control the output of the message and stack trace information and would like to "suppress" this information. I have searched around but cannot find a way to do it. Any ideas?

示例web.config条目(用于RollingFileAppender):

Sample web.config entry (for a RollingFileAppender):

<layout type="Example.Class.CustomLog4netLayouts,Example">    
    <conversionPattern value="%date [%thread] [RID:%property{CLIENT_REQUESTID}] 
     %-5level %logger [%property{NDC}] - %cleanmessage - %cleanstack%newline" />
</layout>

谢谢

推荐答案

像这样配置布局:

<layout type="Example.Class.CustomLog4netLayouts,Example">
    <IgnoresException value="False" />
    ...

IgnoresException设置为false会告诉添加程序布局将处理异常.因此,您可以选择不打印堆栈跟踪.

Setting IgnoresException to false tells the appender that the layout will take care of the exception. Thus you can choose not to print the stack trace.

这篇关于Log4net-禁止显示"exception"从附加到自定义"PatternLayout"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆