No appenders could be found for logger(log4j)?

前端 未结 30 2274
[愿得一人]
[愿得一人] 2020-11-22 08:16

I have put log4j to my buildpath, but I get the following message when I run my application:

log4j:WARN No appenders could be found for logger (dao.hsqlmanag         


        
30条回答
  •  既然无缘
    2020-11-22 09:03

    Quick solution:

    1. add code to main function:

      String log4jConfPath = "/path/to/log4j.properties";
      PropertyConfigurator.configure(log4jConfPath);
      
    2. create a file named log4j.properties at /path/to

      log4j.rootLogger=INFO, stdout
      log4j.appender.stdout=org.apache.log4j.ConsoleAppender
      log4j.appender.stdout.Target=System.out
      log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
      log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
      

提交回复
热议问题