Reputation: 10215
I have a Spring Boot 2.6.3 project that uses spring-boot-starter
. When I run the dependecy:tree
goal in maven, I see that spring-boot-starter-logging
depends on both logback
and (indirectly) log4j
. Why does spring-boot-starter-logging
require a dependency on log4-to-slf4j
?
Upvotes: 6
Views: 6555
Reputation: 16185
Spring Boot has bindings for all major logging frameworks. With a single configuration you can concentrate logs sent through SLF4J, Log4j 2.x API or java.util.logging
.
Therefore the spring-boot-starter-logging
provides:
logback-classic
), which uses SLF4J as native API,log4j-to-slf4j
). Remark that this is not the standard Log4j 2.x Core implementation.java.util.logging
to SLF4J (jul-to-slf4j
).Remark that spring-boot-starter-log4j2
does the same thing and redirects the frameworks above to Log4j 2.x Core.
The big absent in this picture is Jakarta Commons Logging, which is only able to bind to java.util.logging
(hence not directly to neither Logback nor Log4j 2.x Core). However spring-core
depends on spring-jcl
, which binds JCL directly to SLF4J or the Log4j 2.x API and can entirely replace the original JCL.
A fifth API (Log4j 1.x) was supported in Spring Boot 1.x.
Upvotes: 4