No appenders could be found for logger(log4j)?

前端 未结 30 2261
[愿得一人]
[愿得一人] 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:13

    I get the same error. Here the problem which leads to this error message:

    I create some objects which use the Logger before I configure the log4j:

    Logger.getLogger(Lang.class.getName()).debug("Loading language: " + filename);
    

    Solution: Configure the log4j at the beginning in the main method:

    PropertyConfigurator.configure(xmlLog4JConfigFile); 
    // or BasicConfigurator.configure(); if you dont have a config file
    

提交回复
热议问题