[Solved]: log4j:WARN No appenders could be found for logger (dao.hsqlmanager). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Problem Statement:

I am getting the following message when I am running my application:

log4j:WARN No appenders could be found for logger (dao.hsqlmanager).log4j:WARN Please initialize the log4j system properly.log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Solution:

you have two simple approaches you can take.

1.  using BasicConfigurator

The first approach is to just add this line to your main method:

BasicConfigurator.configure();

2.  using log4j.properties

The second approach is to add this standard log4j.properties  file to your classpath:

# Set root logger level to DEBUG and its only appender to A1.log4j.rootLogger=DEBUG, A1# A1 is set to be a ConsoleAppender.log4j.appender.A1=org.apache.log4j.ConsoleAppender# A1 uses PatternLayout.log4j.appender.A1.layout=org.apache.log4j.PatternLayoutlog4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

you need to add the location of your log4j.properties file to the Classpath in Eclipse.

Make sure your project is open in Eclipse, then click on the “Run” menu at the top of Eclipse and click on the following:

    1. Run as
    2. Run Configurations
    3. Classpath (tab)
    4. User Entries
    5. Advanced (button on the right)
    6. Add Folders
    7. then navigate to the folder that contains your log4j.properties file
    8. Apply
    9. Run

    Trick: If you are putting log4j.properties in src/main/resources. By setting src/main/resources in build path will resolve this problem.


    That’s it.