Skip to content

Commit 890f29e

Browse files
vananievsdeleuze
authored andcommitted
Add spring-jcl information to reference doc
Closes gh-22158
1 parent 79dfda7 commit 890f29e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/docs/asciidoc/core.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ include::core/core-null-safety.adoc[leveloffset=+1]
3737

3838
include::core/core-databuffer-codec.adoc[leveloffset=+1]
3939

40+
include::core/core-spring-jcl.adoc[leveloffset=+1]
41+
4042
include::core/core-appendix.adoc[leveloffset=+1]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[[spring-jcl]]
2+
= Logging
3+
4+
Spring Framework since 5.0 comes with its own Commons Logging bridge implemented
5+
in `spring-jcl` module. The implementation checks for the presence of the Log4j 2.x API
6+
and the SLF4J 1.7 API in the Spring Framework classpath, falling back to JUL if none of
7+
the two is available. Note that this Commons Logging variant is only meant to be used
8+
for infrastructure logging purposes in the core framework and in extensions.
9+
10+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
11+
.Java
12+
----
13+
public class MyBean {
14+
private final Log log = LogFactory.getLog(getClass());
15+
// ...
16+
}
17+
----
18+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
19+
.Kotlin
20+
----
21+
class MyBean {
22+
private val log = LogFactory.getLog(javaClass)
23+
// ...
24+
}
25+
----
26+
27+
Log implementation may be instantiated by `org.apache.commons.logging.LogFactory`.
28+
29+
For logging need in application code, prefer direct use of Log4j 2.x or SLF4J or JUL.
30+
Simply put Log4j 2.x or Logback (or another SLF4J provider) onto your classpath, without
31+
any extra bridges, and let the framework auto-adapt to your choice. For further information see
32+
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-logging[Spring Boot Logging Reference Documentation].

0 commit comments

Comments
 (0)