As of log4j version 0.8.5, at class initialization time class, the file log4j.properties will be searched from the search path used to load classes. If the file can be found, then it will be fed to the configure(java.net.URL) method.
I am guessing this is used for initialization, and looking for log4j.properties in the classpath.
But i am trying to override that config file by using
and javadoc doesnt say how PropertyConfigurator.configure behaves
I think whatever the App server we use, the log4j.properties file for any application should be inside the directory structure of that application.
Like if we have a webapplication then as Martijn said , the best location would be "WEB-INF\classes". It might be the way we load the properties file that would cause the problem of not finding the log4j.properties file.
I faced this problem couple of times but resolved it using
getResourceAsStream() looks for the file in classpath and hence can find one if put in "WEB-INF\classes" directory.