Thursday, 20 November 2008

Log4j warning message [log4j:WARN No appenders could be found for logger]

Log4j:

Log4j is a logging or tracing API, large number of applications and framework use Log4j for logging.


Problems:

Sometimes application do not generate log files and generate the following warning message.

log4j:WARN No appenders could be found for logger (com.test.HelloWorld).
log4j:WARN Please initialize the log4j system properly.


Reasons:

Log4j is not initialised properly. The Log4j library files are in application class path but Log4j configuration file is not in application class path.


Solution:

Add log4j configuration file [log4j.properties or log4j.xml] to class path.


More Info:

Log4j priority order,
FATAL: 50000
ERROR: 40000
WARN: 30000
INFO: 20000
DEBUG: 10000

Ref:
log4j Manual
log4j API

No comments: