Wednesday, October 19, 2011

Why Log4j is not logging?


Recently I had a problem with the log mechanism in a small system I had to maintain.

It simply was ignoring log4j.properties configuration and was logging messages with INFO level.

After some time I discovered that it was using common-logging instead pure log4j.

There is no problem using commons-logging, it does work fine. The real problem was that only commons-logging-api.jar and log4j.jar were included in classpath. It was missing commons-logging.jar.

To support log4j, commos-logging needs both jars in classpath: commons-logging and commons-logging-api.

After adding commons-logging.jar in the classpath, log4j.properties started being read and respected.

Read more about commons-logging here: http://commons.apache.org/logging/guide.html#Jars Included in the Standard Distribution

No comments:

Post a Comment