Skip to content

Commit deae981

Browse files
committed
Remove log4j-core dependency from SLF4J bridges
To prepare for the migration between Log4j Core 2 and Log4j Core 3 this PR removes the runtime dependency on `log4j-core` from both `log4j-slf4j-impl` and `log4j-slf4j2-impl`. This explicitly reverts the changes in [LOG4J2-3601](https://issues.apache.org/jira/browse/LOG4J2-3601)
1 parent 832cade commit deae981

File tree

5 files changed

+99
-20
lines changed

5 files changed

+99
-20
lines changed

log4j-slf4j-impl/pom.xml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,71 +49,83 @@
4949
</dependencyManagement>
5050

5151
<dependencies>
52+
5253
<dependency>
5354
<groupId>org.osgi</groupId>
5455
<artifactId>org.osgi.core</artifactId>
5556
<scope>provided</scope>
5657
</dependency>
58+
5759
<dependency>
5860
<groupId>org.apache.logging.log4j</groupId>
5961
<artifactId>log4j-api</artifactId>
6062
</dependency>
63+
6164
<dependency>
6265
<groupId>org.slf4j</groupId>
6366
<artifactId>slf4j-api</artifactId>
6467
</dependency>
68+
6569
<dependency>
6670
<groupId>org.apache.logging.log4j</groupId>
67-
<artifactId>log4j-core</artifactId>
68-
<scope>runtime</scope>
71+
<artifactId>log4j-api-test</artifactId>
72+
<scope>test</scope>
6973
</dependency>
74+
7075
<dependency>
7176
<groupId>org.apache.logging.log4j</groupId>
72-
<artifactId>log4j-api-test</artifactId>
77+
<artifactId>log4j-core</artifactId>
7378
<scope>test</scope>
74-
<exclusions>
75-
<exclusion>
76-
<groupId>org.slf4j</groupId>
77-
<artifactId>slf4j-api</artifactId>
78-
</exclusion>
79-
</exclusions>
8079
</dependency>
80+
8181
<dependency>
8282
<groupId>org.apache.logging.log4j</groupId>
8383
<artifactId>log4j-core-test</artifactId>
8484
<scope>test</scope>
8585
</dependency>
86+
8687
<dependency>
8788
<groupId>org.apache.logging.log4j</groupId>
8889
<artifactId>log4j-to-slf4j</artifactId>
8990
<scope>test</scope>
90-
<exclusions>
91-
<exclusion>
92-
<groupId>org.slf4j</groupId>
93-
<artifactId>slf4j-api</artifactId>
94-
</exclusion>
95-
</exclusions>
9691
</dependency>
92+
93+
<dependency>
94+
<groupId>org.assertj</groupId>
95+
<artifactId>assertj-core</artifactId>
96+
<scope>test</scope>
97+
</dependency>
98+
9799
<dependency>
98100
<groupId>org.apache.commons</groupId>
99101
<artifactId>commons-csv</artifactId>
100102
<scope>test</scope>
101103
</dependency>
104+
102105
<dependency>
103106
<groupId>org.apache.commons</groupId>
104107
<artifactId>commons-lang3</artifactId>
105108
<scope>test</scope>
106109
</dependency>
110+
107111
<dependency>
108112
<groupId>org.junit.jupiter</groupId>
109113
<artifactId>junit-jupiter-engine</artifactId>
110114
<scope>test</scope>
111115
</dependency>
116+
117+
<dependency>
118+
<groupId>org.junit.jupiter</groupId>
119+
<artifactId>junit-jupiter-params</artifactId>
120+
<scope>test</scope>
121+
</dependency>
122+
112123
<dependency>
113124
<groupId>org.junit.vintage</groupId>
114125
<artifactId>junit-vintage-engine</artifactId>
115126
<scope>test</scope>
116127
</dependency>
128+
117129
</dependencies>
118130
<build>
119131
<plugins>

log4j-slf4j2-impl/pom.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,69 +50,83 @@
5050
</dependencyManagement>
5151

5252
<dependencies>
53+
5354
<dependency>
5455
<groupId>org.osgi</groupId>
5556
<artifactId>org.osgi.core</artifactId>
5657
<scope>provided</scope>
5758
</dependency>
59+
5860
<dependency>
5961
<groupId>org.apache.logging.log4j</groupId>
6062
<artifactId>log4j-api</artifactId>
6163
</dependency>
64+
6265
<dependency>
6366
<groupId>org.slf4j</groupId>
6467
<artifactId>slf4j-api</artifactId>
6568
</dependency>
69+
6670
<dependency>
6771
<groupId>org.apache.logging.log4j</groupId>
68-
<artifactId>log4j-core</artifactId>
69-
<scope>runtime</scope>
72+
<artifactId>log4j-api-test</artifactId>
73+
<scope>test</scope>
7074
</dependency>
75+
7176
<dependency>
7277
<groupId>org.apache.logging.log4j</groupId>
73-
<artifactId>log4j-api-test</artifactId>
78+
<artifactId>log4j-core</artifactId>
7479
<scope>test</scope>
7580
</dependency>
81+
7682
<dependency>
7783
<groupId>org.apache.logging.log4j</groupId>
7884
<artifactId>log4j-core-test</artifactId>
7985
<scope>test</scope>
8086
</dependency>
87+
8188
<dependency>
8289
<groupId>org.apache.logging.log4j</groupId>
8390
<artifactId>log4j-to-slf4j</artifactId>
8491
<scope>test</scope>
8592
</dependency>
93+
8694
<dependency>
8795
<groupId>org.assertj</groupId>
8896
<artifactId>assertj-core</artifactId>
8997
<scope>test</scope>
9098
</dependency>
99+
91100
<dependency>
92101
<groupId>org.apache.commons</groupId>
93102
<artifactId>commons-csv</artifactId>
94103
<scope>test</scope>
95104
</dependency>
105+
96106
<dependency>
97107
<groupId>org.apache.commons</groupId>
98108
<artifactId>commons-lang3</artifactId>
99109
<scope>test</scope>
100110
</dependency>
111+
101112
<dependency>
102113
<groupId>org.junit.jupiter</groupId>
103114
<artifactId>junit-jupiter-engine</artifactId>
104115
<scope>test</scope>
105116
</dependency>
117+
106118
<dependency>
107119
<groupId>org.junit.jupiter</groupId>
108120
<artifactId>junit-jupiter-params</artifactId>
109121
<scope>test</scope>
110122
</dependency>
123+
111124
<dependency>
112125
<groupId>org.junit.vintage</groupId>
113126
<artifactId>junit-vintage-engine</artifactId>
114127
<scope>test</scope>
115128
</dependency>
129+
116130
</dependencies>
117131
<build>
118132
<plugins>

src/changelog/.2.x.x/.release-notes.adoc.ftl

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,51 @@
2222

2323
This releases contains ...
2424

25-
=== JMX changes
25+
=== SLF4J implementations (bridges)
2626

27-
Starting in version 2.24.0, JMX support is disabled by default and can be re-enabled via the `log4j2.disableJmx=false` system property.
27+
To prepare for the migration between Log4j Core 2 and Log4j Core 3, the
28+
xref:components.adoc#log4j-slf4j-impl[`log4j-slf4j-impl`]
29+
and
30+
xref:components.adoc#log4j-slf4j-impl[`log4j-slf4j2-impl`]
31+
bridges between SLF4J and Log4j API, no longer depend on Log4j Core 2.
32+
Users should specify the logging implementation of their choice explicitly in their dependency manager:
33+
34+
[tabs]
35+
====
36+
Maven::
37+
+
38+
We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
39+
+
40+
[source,xml]
41+
----
42+
<!-- Bridge from SLF4J 2 to Log4j API -->
43+
<dependency>
44+
<groupId>org.apache.logging.log4j</groupId>
45+
<artifactId>log4j-slf4j2-impl</artifactId>
46+
<scope>runtime</scope>
47+
</dependency>
48+
49+
<!-- Log4j API implementation -->
50+
<dependency>
51+
<groupId>org.apache.logging.log4j</groupId>
52+
<artifactId>log4j-core</artifactId>
53+
<scope>runtime</scope>
54+
</dependency>
55+
----
56+
57+
Gradle::
58+
+
59+
We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
60+
+
61+
[source,groovy]
62+
----
63+
// Bridge from SLF4J 2 to Log4j API
64+
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl'
65+
// Log4j API implementation
66+
runtimeOnly 'org.apache.logging.log4j:log4j-core'
67+
----
68+
====
69+
70+
See xref:manual/installation.adoc#impl-core[Installing Log4j Core] for more details.
2871

2972
<#include "../.changelog.adoc.ftl">
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="https://logging.apache.org/xml/ns"
4+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+
type="changed">
6+
<description format="asciidoc">Removes Log4j Core from the runtime dependencies of `log4j-slf4j-impl` and
7+
`log4j-slf4j2-impl`
8+
</description>
9+
</entry>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See xref:manual/installation.adoc#impl-core[Installing Log4j Core]

0 commit comments

Comments
 (0)