4

My log4j is working fine when I run "java pakcage.Main" from command line, but when I run the same program using executable jar like "java -jar myjar.jar" I'm getting the following err:

log4j:WARN No appenders could be found for logger
log4j:WARN Please initialize the log4j system properly

log4j.jar and log4j.properties are threre in my manifest's Class-Path.

I'm sure it worked properly once, but after rebuild it is not working.

1
  • a properties file can't be in a classpath. A jar or directory can be, but not a properties file. The directory containing log4j.properties (or the jar containing it) should be in the classpath. Commented Aug 27, 2011 at 15:34

3 Answers 3

4

You can only list jar files or directories as part of a classpath. Instead of specifying log4j.properties you should specify the directory that the properties file is in relative to the jar being executed.

Example:

If myjar.jar in the base directory, log4j.jar in ./lib/ and log4j.properties in ./conf/

The Class-Path entry in myjar.jar as follows

Class-Path: lib/log4j.jar conf/

Sign up to request clarification or add additional context in comments.

Comments

1

I believe you should also be able to simply include your log4j.xml (or log4j.properties) file inside of your custom Jar file. As long as it is in the root of your Jar file, the log4j framework will be able to find it.

Comments

0

Does this help ?

http://marc.info/?l=log4j-user&m=105168892203831&w=3

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.