Try a solution that provides the filename only and use the application context or ClassLoader to find the file.
1) Use the web.xml init setting to define the different files via conguration (use the file name, no '..', no slashes) 2) Place the file in the WEB-INF directory (so it is off the web-app classpath) 3) Check the ServletContext API and use getResource to find a URL to the file (use the value directly from the init parameters) 4) Pass this to the PropertyConfigurator as a URL
This may not be exactly right, but it should work overall and it should work for your requirements. The other way is to allow the file to be loaded from the web app classpath and just place other values earlier on the classpath, then they will be picked up earlier.
Joined: Oct 14, 2005
I finally found a solution :
Now I try to use a xml format for the log4j config file.
And then the code should be (I think) :
Unfortunatly this code doesn't work. I'm working with Tomcat 5.0.28 (configured with a xml file for log4j logging), log4j-1.2.12, JDK 1.4.2_09
Somebody have an idea ?
PS : Thank to David and Ben for their help
Joined: Mar 30, 2005
For using xml property files in log4j, instead of calling PropertyConfigurator.configurer(), call DOMConfigurator.configurer()