javaspringspring-bootmaven

I need to force logback 1.5.13 but can't


My Spring Boot 3.4.1 project wants Logback 1.5.12 from the spring-boot-starter-web dependency.

I have tried including Logback as a top-level dependency and excluded it from the spring boot start web (doesn't work):

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>

I have tried dependency management:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>1.5.13</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Then my dependency tree looks like this, and still does not work:

[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:3.4.1:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:3.4.1:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:3.4.1:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:3.4.1:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:3.4.1:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.5.12:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.5.13:compile

How can I force this newer version?


Solution

  • You seem to have added dependency on logback-core and fixed its version to 1.5.13. The dependency tree shows logback-classic using 1.5.12.

    I think you need to add another section with logback-classic and 1.5.12 version. Possibly you can get away with replacing the logback-core entry.

    i.e. try

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.5.13</version>
    </dependency>