[英]log4j - How to limit the log of a package/class for an appender
I am using the log4j.properties, and I have an appender called RDev. 我正在使用log4j.properties,并且有一个名为RDev的附加程序。
I want set the level of RDev appender to DEBUG except for specific packages (HTMLUnit in my case) 我想将RDev附加程序的级别设置为DEBUG(特定程序包除外)(以我的情况为HTMLUnit)
My current log4j.properties is like this: 我当前的log4j.properties是这样的:
log4j.rootLogger=debug RDev, test
log4j.appender.RDev=org.apache.log4j.RollingFileAppender
log4j.appender.RDev.File=D:/logs
log4j.appender.RDev.MaxFileSize=5mb
log4j.appender.RDev.MaxBackupIndex=10
log4j.appender.RDev.layout=org.apache.log4j.PatternLayout
log4j.appender.RDev.layout.ConversionPattern=[%5p %d{MMM/dd HH:mm:ss}] [%t] (%F:%L) - %m%n
and I want to filter/remove the DEBUG log of these packages: 我想过滤/删除这些软件包的调试日志:
com.gargoylesoftware.htmlunit
org.apache.commons.httpclient
org.apache.http.impl.conn
* UPDATE * I tried this and it works for all appendars: * 更新*我试过了,它适用于所有附录:
# Set specific logger levels.
log4j.logger.org.mortbay.log=fatal
log4j.logger.org.apache.http=fatal
log4j.logger.org.apache.http.headers=fatal
log4j.logger.org.apache.http.wire=fatal
(from https://code.google.com/p/spidey/wiki/HtmlUnitErrors ) (来自https://code.google.com/p/spidey/wiki/HtmlUnitErrors )
Now the question is how to limit this configs to one appendar? 现在的问题是如何将此配置限制为一个附录? (not all of them) (eg I want to see the debugs in the file, not console.)
(不是全部)(例如,我想查看文件中的调试信息,而不是控制台中的信息。)
Do you still want to see log lines for levels that are above DEBUG for those packages? 您是否仍然希望查看那些软件包的调试级别以上的日志行? If so, this log4j tutorial from Apache describes one way to do that;
如果是这样,Apache的log4j教程描述了一种实现方法。 look a bit more than halfway down, at the text that reads "Suppose we are no longer interested in seeing the output of any component belonging to the com.foo package."
看起来比一半还多,上面写着“假设我们不再希望看到属于com.foo包的任何组件的输出”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.