No appenders could be found for logger(log4j)?

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

    First of all: Create a log4j.properties file

    # Root logger option
    log4j.rootLogger=INFO, stdout
    
    # Direct log messages to 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{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
    

    Place it in src/main/resources/

    After that, use this 2 dependencies:

    
                org.slf4j
                slf4j-api
                1.7.5
            
            
                org.slf4j
                slf4j-log4j12
                1.7.5
            
    

    It is necessary to add this final dependency to POM file:

    
            
                org.springframework
                spring-context
                5.1.5.RELEASE
            
    

提交回复
热议问题