3

I have been working on a java project in eclipse that is run via a batch file and uses log4j. Using a log4j.properties file and custom levels using filters so only that level was written to the log file of that level. And it worked fine.

Then I mavenized my project, putting the log4j.properties file in src/main/resources/. And the program runs fine, but the logs are all messed up. The filters are no longer being respected, so log files have logs from every custom level above it; instead of just that level. Now this error only happens when I run it via batch file. If I compile and run the logs work properly.

My CLASSPATH variable in the batch file has all the jar files and all the classes in target/classes.

I'm not sure what to do or where the problem might be, so any help or advice would be appreciated.

Richard
  • 239
  • 1
  • 3
  • 14

1 Answers1

0

I do not think the behaviour indicates there is no log4j.properties on the classpath. If there is no such file, log4j does not initialize (unless told so via code). Uninitialized log4j just emits a message that it is uninitialized - after that the application runs but no logging will happen.

The behaviour you describe indicates that there might be some other log4j.properties on the classpath than you expect. Be aware this is a normal legal situation, and you may want to check you classpath contents (in the specified sequence) to see if there is such a file and whether it contains the expected content.

Queeg
  • 7,748
  • 1
  • 16
  • 42