I am using the log4j.properties, and I have an appender called RDev.

I want set the level of RDev appender to DEBUG except for specific packages (HTMLUnit in my case)

My current log4j.properties is like this:

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)

Now the question is how to limit this configs to one appendar? (not all of them) (e.g. 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; 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."

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top