No appenders could be found for logger(log4j)?

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

    I faced the same problem when I use log4j2. My problem is caused by using wrong dependent library:

    
            org.slf4j
            slf4j-log4j12
            runtime
        
    

    Instead, I should use:

    
            org.apache.logging.log4j
            log4j-slf4j-impl
            runtime
        
    

    In my case, I have a log4j2.xml defined in my "resources" directory, and specified to use it by:

    System.setProperty("log4j.configurationFile", "log4j2.xml");
    

提交回复
热议问题