Commons logging question

J

James Zhou

Hi all, I am working on an application that uses jakarta commons
logging package to log message. Since I put the log4j jar file under
the classpath, I would assume log4j library is used by commons logging.
Here is my question: if I put two log4j.properties config files into
different directories, and both directories are part of classpath,
which log4j.properties config file will be taken? How to debug this
kind of classpath problems?

Thanks,
 
R

Ryan Stewart

James Zhou said:
Hi all, I am working on an application that uses jakarta commons
logging package to log message. Since I put the log4j jar file under
the classpath, I would assume log4j library is used by commons logging.
Here is my question: if I put two log4j.properties config files into
different directories, and both directories are part of classpath,
which log4j.properties config file will be taken? How to debug this
kind of classpath problems?

Thanks,
The first one that is found. What do you mean "debug"? What is the problem?
 
J

JamesZ

Sometimes I find that the change I made on one log4j.properties file
didnt take effective. Maybe there is another log4j.properties file that
takes precedence over the file I changed. If the classpath is very
long, It is a pain for me to find out which particular property file is
picked at runtime.
I wonder if there is a way to print out the exact location of a given
resouce file.
By using the following method, I can get the exact location of a class
file loaded by the Class Loader:
Class a = AObject.getClass();
String location =
a.getProtectionDomain().getCodeSource().getLocation();
System.out.println("location of class = " + location);
But the above wont work for a resouce file.
 
R

Ryan Stewart

JamesZ said:
Sometimes I find that the change I made on one log4j.properties file
didnt take effective. Maybe there is another log4j.properties file that
takes precedence over the file I changed. If the classpath is very
long, It is a pain for me to find out which particular property file is
picked at runtime.
I wonder if there is a way to print out the exact location of a given
resouce file.
By using the following method, I can get the exact location of a class
file loaded by the Class Loader:
Class a = AObject.getClass();
String location =
a.getProtectionDomain().getCodeSource().getLocation();
System.out.println("location of class = " + location);
But the above wont work for a resouce file.
Are we talking about a web application or a standalone application? If the
former, log4j.properties needs to be in WEB-INF/classes. Otherwise control
your classpath better. It can't be that difficult to figure out which file
is being used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top