Disable Logback in SpringBoot

To add a solution in gradle.

dependencies {
    compile ('org.springframework.boot:spring-boot-starter') {
        exclude module : 'spring-boot-starter-logging'
    }
    compile ('org.springframework.boot:spring-boot-starter-web') {
        exclude module : 'spring-boot-starter-logging'
    }
}

Add exclusion to both the spring-boot-starter and spring-boot-starter-web to resolve the conflict.

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>

To add a better, more generic solution in Gradle (all instances will be excluded):

configurations {
    all*.exclude module : 'spring-boot-starter-logging'
}

From https://docs.gradle.org/current/userguide/dependency_management.html


I found that excluding the full spring-boot-starter-logging module is not necessary. All that is needed is to exclude the org.slf4j:slf4j-log4j12 module.

Adding this to a Gradle build file will resolve the issue:

configurations {
    runtime.exclude group: "org.slf4j", module: "slf4j-log4j12"
    compile.exclude group: "org.slf4j", module: "slf4j-log4j12"
}

See this other StackOverflow answer for more details.

Tags:

Spring Boot