Skip to content

Log4J doesn’t understand your command-line pointer to log4j.properties?

July 26, 2012

I had to answer this question more than once, so it’s probably worth posting in case somebody else out there is looking for the answer.

Are you getting this error message when trying to run a class that uses Log4J?

log4j:WARN No appenders could be found for logger (ldif.local.Ldif$).
log4j:WARN Please initialize the log4j system properly.

Are you specifying a pointer to your log4j.properties file like this?

java -Xmx2G -Xms256M -Dlog4j.configuration=file:../resources/log4j.properties [MainClass]

The part that most people forget is that “file:” before the path to log4j.properties. Check that once more and try again. 🙂

If you are using IntelliJ IDEA, the place to set that is under “Run / Edit Configurations / (choose your class under Applications) / VM options”.

Advertisements

From → tech-tips

4 Comments
  1. Manolo permalink

    Thanks! It worked for me.

  2. Rohan permalink

    Thank you

  3. The syntax set JAVA_OPT=%JAVA_OPT% -Dlog4j.configuration=file:../config/log4j.properties
    works also in.cmd script for windows for reading the log4j configurations.

  4. Could you be more specific about what to input into IntelliJ? I tried

    java -Xmx2G -Xms256M -Dlog4j.configuration=file:../resources/log4j.properties [MainClass]

    -Dlog4j.configuration=file:../resources/log4j.properties [MainClass]

    java -Xmx2G -Xms256M -Dlog4j.configuration=file:../resources/log4j.properties

    None of these options worked.
    (I also tried the suggestion for the cmd script in windows while running my code there, and it didn’t seem to make a difference. Any suggestions are appreciated!)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: