Reputation: 1984
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:
jdom-2.0.5.jar
log4j-1.2.17.jar
ojdbc7.jar
quartz-2.2.1.jar
slf4j-api-1.7.7.jar
slf4j-log4j12-1.7.7.jar
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
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