user835745
user835745

Reputation: 1984

log4j likes its properties in a jar file?

I have a Java application which I'm executing on Linux direct from an executable jar file

java -cp .:./lib -Duser.timezone=GMT -Dlog4j.debug -jar programName.jar

The program uses a number of other jar files which are all in one directory and 4 properties files all of which are in another directory (the current directory). Both directories are included in the CLASSPATH.

Simple enough right.

It would be, except that Log4j fails to find log4j.properties. The only way I have managed to make it find log4j.properties is to include it in programName.jar

This is not what I want, I want to have it using log4j.properties residing in the same directory as all the other properties files, they are in the CLASSPATH and are found as you would expect.

The other jar files being used are:

I'm wondering if slf4j-log4j12-1.7.7.jar does some configuration which prevents log4j from scanning the CLASSPATH when looking for the properties file. My code does not include any instructions which aim to specify the location of the properties file.

I've not yet tried executing the program without the -jar option, I will try that next.

Does this ring any bells so far ?

Upvotes: 0

Views: 631

Answers (1)

Paul Vargas
Paul Vargas

Reputation: 42020

Add an argument to jvm (log4j.configuration). e.g.:

java -cp .:./lib -Dlog4j.configuration=file:log4j.properties -Duser.timezone=GMT ...

You may want to see this answer for more options.

Upvotes: 1

Related Questions