First off, I apologize if this question has already been asked. I searched but couldn't find anything specific to my problem.
Here's the scenario - I'm deploying an application, say, MyFirstWebApp in Tomcat 6.0.35. Tomcat has a log4j.properties in it's common loader path which looks like -
log4j.rootLogger=INFO, LOGFILE
log4j.logger.com.test.java=DEBUG, TEST
log4j.additivity.com.test.java=false
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
# LOGFILE is set to be a File appender using a PatternLayout
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.LOGFILE.File=/home/myuserid/tomcat.log
log4j.appender.LOGFILE.MaxFileSize=25MB
log4j.appender.LOGFILE.MaxBackupIndex=5
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d %p %t %c - %m%n
# LOGFILE is set to be a File appender using a PatternLayout
log4j.appender.TEST=org.apache.log4j.FileAppender
log4j.appender.TEST.File=/home/myuserid/test.log
log4j.appender.TEST.layout=org.apache.log4j.PatternLayout
log4j.appender.TEST.layout.ConversionPattern=%d %p %t %c - %m%n
Tomcat also has a log4j.jar file in it's lib/ directory.
Now, MyFirstWebApp has a log4j.properties inside it's WEB-INF/classes directory. MyFirstWebApp also has a log4j.jar in it's WEB-INF/lib directory.
MyFirstWebApp log4j.properties looks like this -
log4j.rootCategory=INFO,LOGFILE
# Set the enterprise logger priority to FATAL
log4j.logger.com.test=INFO
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.LOGFILE.MaxFileSize=10MB
log4j.appender.LOGFILE.MaxBackupIndex=99
log4j.appender.LOGFILE.File=/home/myuserid/mywebapp.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
When I start the server and deploy this application, I expected to find 3 log files - tomcat.log, test.log and mywebapp.log (which I did). I also expected to find all logging from "com.test.java" package inside "test.log" but they were found in "mywebapp.log"
What am I doing wrong here? How can I log messages from "com.test.java" without modifying MyFirstWebApp?