Different webapps using different log4j.properties file.

Ryan Breidenbach

Additional information

I have two webapps, called example1 and example2. Each of them have own log4j.conguration. For example1 webapps, it is example1.txt and for example2 webapps, it is example2.txt.

Since I am using Tomcat, can I set up the log4j.configuation in Unix like:
export TOMCAT_OPTS= "-Dlog4j.configuration="/m1/example1/WEB-INF/classes/example1.txt"
export TOMCAT_OPTS="-Dlog4j.configuration="/m1/example2/WEB-INF/classes/example2.txt"

And finally, if I can set up the TOMCAT_OPTS in unix, then how should I call the PropertyConfigurator.configure(??) in each webapps? In order what should (??) contains in example1 and example2 webapps?

There is probably an easier way than setting tomcat environment variables. You can also provide default initialization by placing a file named log4j.properties in your classpath. So, for each of you webapps under tomcat, simply place your log4j.properties file in the WEB-INF/classes directory and log4j will automagically be configured.

For more information on the steps log4j follows to configure itself, see the Default Initialization Procedure section of the log4j manual.

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact