I am using Spring Boot 4.0.0-M1 + Webflux + Log4j.
In Spring Boot 3.x, I did this as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</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-log4j2</artifactId>
</dependency>
In Spring Boot 4.0.0-M1, this no longer works because the spring-boot-starter-aop started including logback:
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:4.0.0-M1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:4.0.0-M1:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:4.0.0-M1:compile
[INFO] | | | \- org.springframework.boot:spring-boot-starter-logback:jar:4.0.0-M1:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.5.18:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.5.18:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.24.3:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:2.0.17:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:4.0.0-M1:compile
[INFO] | | \- org.yaml:snakeyaml:jar:2.4:compile
[INFO] | +- org.springframework:spring-aop:jar:7.0.0-M7:compile
[INFO] | | \- org.springframework:spring-beans:jar:7.0.0-M7:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.9.24:compile
The pom/gradle will quickly get out of hand if we need to exclude logback from multiple modules.
P.S. it DOES work if I exclude it from both :), just pointing out that previously we only had to exclude from one starter. With the new starter layout ... it may be in other starters as well, but for my dependencies, its only in the aop starter so far.
Comment From: snicoll
In Spring Boot 4.0.0-M1, this no longer works because the spring-boot-starter-aop started including logback
That's not new. The starter AOP always included the main starter that itself includes logback by default.
There is only one reference to spring-boot-starter-logging
so I am not sure what you've claimed comes from.
Comment From: snicoll
In Spring Boot 3.x, I did this as follows:
That's the wrong way, please review the documentation.
Comment From: SledgeHammer01
In Spring Boot 3.x, I did this as follows:
That's the wrong way, please review the documentation.
Thanks. The way I showed DOES work in 3.x and keeps the logback dependencies out and only had to exclude from the Webflux dependency. I switched over to the way you linked and that works.