3
spring4 使用logback不打印日志 - CSDN博客 (blog.csdn.net)
natsu 積分 0

在 pom.xml 中,則要使用如下設定:

  1. spring-context 不要引用 commons-logging
  2. 改用 jcl-over-slf4jlogback-classic
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${spring-framework.version}</version>
    <exclusions>
        <!-- Exclude Commons Logging in favor of SLF4j -->
        <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
...
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.6.1</version>
</dependency>
<!-- for slf4j v1.6.1 -->
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>0.9.29</version>
</dependency>