I have a web-app where a log4j.xml has been defined which specifies an appender to output to console only. This web-app is being deployed in Tomcat7 in WIndows environment. I need to include a log4j.xml which would specify appenders to output to the console as well as a file. I have created the log4j.xml and placed it in the conf folder for the same and have followed the steps to bootstrap log4j to tomcat.
PROBLEM:
I have tried modifying the catalina.bat file to update LOGGING_CONFIG to look up CATALINA_HOME/conf/log4j.xml but it did not work.I am unable to configure tomcat to pick the log4j in the conf folder. It always picks the one in the web-app. I was able to get some more info on the problem by including the below lines in catalina.bat file.
rem To get details on the instiation of the log4j
set JAVA_OPTS=-Dlog4j.debug
It gave me the below output
log4j: Trying to find [log4j.xml] using context classloader WebappClassLoader
context:
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@7daf6ecc
.
log4j: Using URL [file:/C:/whp-tomcat-7/webapps/ROOT/WEB-INF/classes/log4j.xml] for automatic log4j configuration.
I figured that it has something to do with the way the the log4j class loader looks up for log4j.xml. Can somebody please help me defining the heirarchy so that I am able to configure Tomcat to pick up the log4j.xml from the conf folder at catalina home?
Thanks in advance