aspose file tools*
The moose likes Other Open Source Projects and the fly likes Problem with log4j properties file path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Problem with log4j properties file path" Watch "Problem with log4j properties file path" New topic
Author

Problem with log4j properties file path

Tushar Madhukar
Ranch Hand

Joined: May 03, 2006
Posts: 36
Hi,

I have created an standalone application that is completely bundled in jar file. I would like to use log4j for logging purposes.

Is it possible to package the log4j.properties file in the jar itself, so that the PropertyConfigurator can find it at runtime? I tried putting the properties file at the root of the jar, but log4j is not able to find it there.

Can anybody suggest how can this be done?

Thx
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10059
    
163

I havent tried this, but i think the log4j.properties file will have to be in the same folder as the jar file. However, i do think that placing the log4j.properties file in the jar should have worked. To see how log4j is trying to look for the properties file, you can try out the following:

Know how log4j tries to configure itself


[My Blog] [JavaRanch Journal]
Ruth J
Greenhorn

Joined: Sep 04, 2008
Posts: 1
You can use an external log4j.properties file that is not in your jar.

Do this: In your manifest set the class-path:

Example:
Class-Path: ./WEB-INF/lib/log4j-1.2.9.jar ./WEB-INF/lib/

That second entry is going to be where you put the log4j.properties file in relation to your jar.

Don't package the log4j.properties file in your jar.

Execute your jar like: java -jar myapp.jar (don't put any classpath options)

Now you can change the settings in your log4j.properties file and not have to repackage it in your jar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with log4j properties file path