log4j:WARN No appenders could be found for logger

baby by side

I had written a simple core-java program to test the log4j functionality. I decided to test RollingFileAppender and console appender with that. Everything goes fine, till I run the file. When I run the file I count see the log; instead I have seen a warning like

log4j:WARN No appenders could be found for logger

when I added BasicConfigurator.configure(); I have seen console appender is working fine. But I need to add PropertyConfigurator.configure("log4j.properties") to get the log in the rolling file.

BasicConfigurator is used to do the quick configuration so that the log can be displayed in the screen.

PropertyConfigurator of log4j instructs PropertyConfigurator to parse a configuration file and set up logging accordingly.

You can see a get started guide to log4j in the loose-sheets

Advertisements