Since Spring Framework 5.0, Spring comes with its own Commons Logging bridge implemented in the spring-jcl module. The
implementation checks for the presence of the Log4j 2.x API and the SLF4J 1.7 API in the classpath and uses the first
one of those found as the logging implementation, falling back to the Java platform’s core logging facilities (also
known as JUL or java.util.logging) if neither Log4j 2.x nor SLF4J is available.
自 Spring Framework 5.0 以来,Spring 自带了在 spring-jcl 模块中实现的 Commons Logging 桥接器。该实现检查类路径中是否存在
Log4j 2.x API 和 SLF4J 1.7 API,并使用找到的第一个作为日志实现,如果 Log4j 2.x 和 SLF4J 都不可用,则回退到 Java
平台的核心日志设施(也称为 JUL 或 java.util.logging )。
Put Log4j 2.x or Logback (or another SLF4J provider) in your classpath, without any extra bridges, and let the framework
auto-adapt to your choice. For further information see
the Spring Boot Logging Reference Documentation.
将 Log4j 2.x 或 Logback(或另一个 SLF4J 提供者)放入您的类路径中,无需任何额外桥梁,让框架自动适应您的选择。有关更多信息,请参阅
Spring Boot 日志记录参考文档。
Spring’s Commons Logging variant is only meant to be used for infrastructure logging purposes in the core framework and
in extensions.
Spring 的 Commons Logging 变体仅用于核心框架及其扩展中的基础设施日志记录目的。
For logging needs within application code, prefer direct use of Log4j 2.x, SLF4J, or JUL.
为应用程序代码中的日志需求,优先使用 Log4j 2.x、SLF4J 或 JUL。
A Log implementation may be retrieved via org.apache.commons.logging.LogFactory as in the following example.
一个 Log 实现可以通过 org.apache.commons.logging.LogFactory 检索,如下例所示。