log4net的:配置忽略来自某个特定的类信息 [英] log4net: Configure to ignore messages from a specific class
问题描述
有没有办法让log4net的配置忽略一个特定的类?例如,我们一般创建日志在每一个类。与此类似:
Is there a way to have the log4net configuration ignore a specific class? For example, we generally create a log in every class. Similar to this:
private static readonly ILog Log = log4net.LogManager.GetLogger("MyClass");
问题是 MyClass的
日志数据的极端金额,它会很难找到其他类的信息。它使用 MyClass的
,所以我不能只是去和周围的日志文件的变化,但在我的环境,我想忽略这些其他开发人员。
The problem is MyClass
logs an extreme amount of data and it gets hard to find information about other classes. Its another dev that uses MyClass
so I cannot just go in and change around the log files, but in my environment I would like to ignore these.
可以设置我的配置
文件从一个特定的类忽略这些消息?
Can I set my configuration
file to ignore the messages from a specific class?
推荐答案
当然,使用的过滤器。
下面是贴在博客上的片段,以供将来参考 - 所有的功劳归给博客文章的作者:
Here's the snippet posted on the blog, for future reference - all credit to the author of that blog post:
<filter type="log4net.Filter.LoggerMatchFilter">
<!-- allows this sub-namespace to be logged... -->
<loggerToMatch value="Noisy.Namespace.But.Important" />
</filter>
<filter type="log4net.Filter.LoggerMatchFilter">
<!-- ...but not the rest of it -->
<loggerToMatch value="Noisy.Namespace" />
<acceptOnMatch value="false" />
</filter>
这篇关于log4net的:配置忽略来自某个特定的类信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!