Add spring-jcl information to reference doc

Closes gh-22158
This commit is contained in:
Vitalii Ananev 2019-11-25 10:26:11 +03:00 committed by Sébastien Deleuze
parent 79dfda7369
commit 890f29e832
2 changed files with 34 additions and 0 deletions

View File

@ -37,4 +37,6 @@ include::core/core-null-safety.adoc[leveloffset=+1]
include::core/core-databuffer-codec.adoc[leveloffset=+1]
include::core/core-spring-jcl.adoc[leveloffset=+1]
include::core/core-appendix.adoc[leveloffset=+1]

View File

@ -0,0 +1,32 @@
[[spring-jcl]]
= Logging
Spring Framework since 5.0 comes with its own Commons Logging bridge implemented
in `spring-jcl` module. The implementation checks for the presence of the Log4j 2.x API
and the SLF4J 1.7 API in the Spring Framework classpath, falling back to JUL if none of
the two is available. Note that this Commons Logging variant is only meant to be used
for infrastructure logging purposes in the core framework and in extensions.
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
public class MyBean {
private final Log log = LogFactory.getLog(getClass());
// ...
}
----
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
class MyBean {
private val log = LogFactory.getLog(javaClass)
// ...
}
----
Log implementation may be instantiated by `org.apache.commons.logging.LogFactory`.
For logging need in application code, prefer direct use of Log4j 2.x or SLF4J or JUL.
Simply put Log4j 2.x or Logback (or another SLF4J provider) onto your classpath, without
any extra bridges, and let the framework auto-adapt to your choice. For further information see
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-logging[Spring Boot Logging Reference Documentation].