删除commons-logging-1.1.jar
并添加jcl-over-slf4j-1.5.11.jar
,因为您需要所有日志记录调用都通过 slf4j,然后由 log4j 处理。
此外,您需要在 log4j.properties 中为 spring 添加记录器,如下所示。log4j.properties 需要以tomcat/webapps/<application>/WEB-INF/classes
.
#Spring Framework
log4j.logger.org.springframework=INFO
log4j.logger.org.springframework.oxm=INFO
log4j.logger.org.springframework.transaction=WARN
Maven 依赖项需要包含类似于以下的条目(取自Using SLF4J部分)。
注意排除commons-logging
和包含jcl-over-slf4j
。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>