如何禁用log4net状态消息到控制台? [英] How do I disable log4net status messages to the console?

查看:1395
本文介绍了如何禁用log4net状态消息到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的.NET 3.5控制台应用程序中使用log4net,并希望我生成的日志消息可以在控制台标准输出和RollingFileAppender中看到。文件输出的工作方式类似于charm,但是我看到一个状态消息流到控制台标准输出当我执行。我想跳过所有的状态信息,只看到我以编程方式生成的日志文件中的相同的消息。



这是一个例子,我看到,我的应用程序:

  log4net:XmlHierarchyConfigurator:配置更新模式[合并]。 
log4net:XmlHierarchyConfigurator:Logger [root]级别字符串为[DEBUG]。
log4net:XmlHierarchyConfigurator:Logger [root]级别设置为[name =DEBUG,value = 30000]。
log4net:XmlHierarchyConfigurator:Loading Appender [Console] type:[log4net.Appender.ConsoleAppender]
log4net:PatternParser:Converter [message] Option [] Format [min = -1,max = 2147483647,leftAlign = False]

,它一直持续到描述记录器对象的整个实例。



如何关闭这个功能?我可以吗?我试过各种配置文件设置,但没有什么使这些消失! Grrr ...

解决方案

我刚刚经历了同样的问题(这不奇怪,是我发现这个问题) / p>

无论如何,我的问题,以及可能是您的问题,是由网络/应用配置文件设置< log4net debug = true > 。太明显了,对吧?我从web片段粘贴了我的app.config设置的骨架,并专注于appender,不是真的给根log4net元素一瞥。但你有它。这是在常见问题,但是其他事情抓住了我的眼睛,而不是这个属性。


I am using log4net in my .NET 3.5 console application and would like the log messages I generate to be seen in both the console standard out and the RollingFileAppender. The file output is working like a charm, but I am seeing a stream of status messages flowing to the console standard out when I execute. I would like to skip all the status information and only see the same messages I am programmatically generating to the log file.

Here is an example of what I see after I run my app:

log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
log4net: XmlHierarchyConfigurator: Logger [root] Level string is [DEBUG].
log4net: XmlHierarchyConfigurator: Logger [root] level set to [name="DEBUG",value=30000].
log4net: XmlHierarchyConfigurator: Loading Appender [Console] type: [log4net.Appender.ConsoleAppender]
log4net: PatternParser: Converter [message] Option [] Format [min=-1,max=2147483647,leftAlign=False]

and it keeps on going until it describes the whole instantiation of the logger object.

How do I turn this off? Can I? I've tried all sorts of config file settings, but nothing makes these go away! Grrr...

解决方案

I just went through this same problem (which, unsurprisingly, is how I found this question).

Anyway, my problem, and possibly yours as well, was caused by a web/app config file setting of "<log4net debug=true>". Too obvious, right? I had pasted the skeleton of my app.config settings in from a web snippet, and had focused on the appenders, not really giving the root log4net element a second glance. But there you have it. This is in the FAQ, but again other things caught my eye and not this attribute.

这篇关于如何禁用log4net状态消息到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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