| Author |
Log4j Properties not loaded
|
M Mehta
Ranch Hand
Joined: Aug 03, 2006
Posts: 82
|
|
I am working on a web application and trying to use log4j logging in it. But I am not able to load the log.properties file.
I am using PropertyConfigurator.configure("log.properties"); where log.properties is in classpath. But it gives me in following exception:
However if I try to use the same thing from a stand alone application with main , it works fine.
Can anyone help me know the issue?
Thanks,
Me
|
 |
Rob Spoor
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18365
|
|
PropertyConfigurator.configure(String) uses local files to load from. Try using Class.getResource or ClassLoader.getResource in combination with PropertyConfigurator.configure(URL):
The actual path to the resource may need to be a little different, but this would be the basic idea.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Raj Kamal
Ranch Hand
Joined: Mar 02, 2005
Posts: 400
|
|
Hi,
The first line in the log says
ERROR Could not read configuration file [log.properties].
Since you are working on a web app the properties has to be in the WEB-INF/classes folder of your web application.
Cheers,
Raj.
|
 |
M Mehta
Ranch Hand
Joined: Aug 03, 2006
Posts: 82
|
|
yeah, I put it in the WEB-INF/classes, but still getting the same error.
|
 |
Rob Spoor
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18365
|
|
|
Have you tried my advice already?
|
 |
 |
|
|
subject: Log4j Properties not loaded
|
|
|