Saturday, 22 November 2008

How to enable Log4j logging in Eclipse console window?

Problems:

Could not see the log message in eclipse console window but it shows 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.


Solution:
Add a ConsoleAppender or Appender

Code Sample:
BasicConfigurator.configure();
or
PropertyConfigurator.configure("log4j.xml");


Ref:

Log4j Manual
Log4j API
BasicConfigurator
PropertyConfigurator

No comments: