解決log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)

spring項目常常在啓動tomcat時報以下警告信息:web

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). 
log4j:WARN Please initialize the log4j system properly.

網上大多數的解決方案都是添加一個log4j的配置,然而如今都是8102年了,你們都用的是slf4j+logback,加這個配置並無什麼卵用,這裏給出另外一種方案。spring

因爲歷史緣由,Spring 的日誌使用的是 JCL,咱們只須要將JCL和Slf4j橋接一下,spring就會使用項目的日誌配置,因此引入maven依賴便可:tomcat

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.7.25</version>
</dependency>
相關文章
相關標籤/搜索