views:

26

answers:

1

Hi,

I am using Log4j in my application, and the libraries that I use that also use Log4j are also outputting their logs to the log files that I create. I have already created appenders to redirect the logs of one library to an "other.log" file, but the other libraries keep logging to my main "info.log" file.

This is my log4j.properties. Notice that in the end, I create a category for the library alibrary.apackage and a category for myproject.apackage, so that the library logs go to one appender and the project logs go to another appender.

log4j.rootLogger=ALL,InfoAppender,OtherAppender

# AdminFileAppender - used to log messages in the admin.log file.
log4j.appender.InfoAppender=org.apache.log4j.FileAppender
log4j.appender.InfoAppender.File=info.log
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern= %d{yyyy/MM/dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n
log4j.appender.InfoAppender.Threshold=DEBUG

log4j.appender.OtherAppender=org.apache.log4j.FileAppender
log4j.appender.OtherAppender.File=other.log
log4j.appender.OtherAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.OtherAppender.layout.ConversionPattern= %d{yyyy/MM/dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n
log4j.appender.OtherAppender.Threshold=ALL

log4j.category.alibrary.apackage=DEBUG,OtherAppender
log4j.additivity.com.mchange.v2=false
log4j.category.myproject.apackage=ALL,InfoAppender
log4j.additivity.trackme=false

I still keep getting the following though:

In the "info.log":

...Logs that I want to be here...
Logs that I do not want to be here, that should go to "other.log". Ex.:
2010/10/28 15:29:25,667 [main] DEBUG org.apache.jasper.compiler.JspRuntimeContext  - Parent class loader is: ContextLoader@null
2010/10/28 15:29:25,668 [main] DEBUG org.apache.jasper.servlet.JspServlet  - ...
2010/10/28 15:29:25,668 [main] DEBUG org.apache.jasper.servlet.JspServlet  - IMPORTANT: Do not modify the generated servlets

In the "other.log":

All the logs that I do not want in "info.log" are here. OK.

My question is: How do I redirect all the unwanted logs - that is, logs from other libraries - to the "other.log"?