Hi,
there is a problem loading the default log4j.properties file when using
J2EE (RI). My system has the following configuration:
1. the log4j.jar is placed into my CLASSPATH variable
2. my log4j.properties file is placed into the classpath of my J2EE Application
Now, if I try to create a new Category, log4j complains it cannot find the
log4j.properties file. This is because the log4j.jar is loaded with a
different classloader than my J2EE application: say classloaderA has loaded
my log4j.jar file and classloaderB has loaded my J2EE Application.
ClassloaderA has no knowledge of my J2EE application and therefore cannot
find the log4j.properties file, but classloaderB can find it since it is in
it's classpath!!
I have solved this problem the same way the "loadClass problem" has been
solved in the org.apache.log4j.helpers.Loader class. I have replaced the
following line of code in the Loader.class:
// Let the class loader of clazz and parents (by the delagation
// property) seearch for resource
ClassLoader loader = clazz.getClassLoader();
by:
// Let the class loader of clazz and parents (by the delagation
// property) seearch for resource
ClassLoader loader = null;
if(java1) {
loader = clazz.getClassLoader();
} else {
loader = Thread.currentThread().getContextClassLoader();
}
After this replacement, log4j can succesfully load my default
log4j.properties file! If you think it's ok, perhaps someone can commit it
to cvs?
Maarten
--
Maarten Coene
Katholieke Universiteit Leuven
Dept. Computerwetenschappen Tel: ++32 (0)16/32 78 25
Celestijnenlaan 200A
B-3001 Heverlee
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]