You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2024/09/06 10:20:28 UTC
(logging-log4j2) 01/01: Removes bridges from Log4j 3
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch feature/main/remove-bridges
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit abade1e085aad1eb7522ece862b54498a3efa46f
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Fri Sep 6 12:20:16 2024 +0200
Removes bridges from Log4j 3
The `log4j-slf4j-impl`, `log4j-slf4j2-impl`, `log4j-to-jul` and `log4j-to-slf4j` bridges are practically identical to their
2.x counterparts.
Unlike `log4j-jpl` (which requires Java 11) and `log4j-jul` (which requires breaking changes to remove optional `log4j-core` dependency), these bridges do not profit from a new release.
As agreed on [`dev@logging`](https://lists.apache.org/thread/hmngcrtw4fmc6zx59rsowllv6cnb01jr), this PR removes them and cleans up the dependencies they used.
---
log4j-core-test/pom.xml | 53 ++-
log4j-jndi-test/pom.xml | 4 -
log4j-mongodb/pom.xml | 33 +-
log4j-osgi-test/pom.xml | 42 ++-
log4j-parent/pom.xml | 48 ---
log4j-perf-test/pom.xml | 91 ++++-
log4j-slf4j-impl/pom.xml | 163 ---------
.../java/org/apache/logging/slf4j/Log4jLogger.java | 390 --------------------
.../apache/logging/slf4j/Log4jLoggerFactory.java | 71 ----
.../org/apache/logging/slf4j/Log4jMDCAdapter.java | 58 ---
.../java/org/apache/logging/slf4j/Log4jMarker.java | 126 -------
.../apache/logging/slf4j/Log4jMarkerFactory.java | 151 --------
.../logging/slf4j/SLF4JLoggingException.java | 41 ---
.../org/apache/logging/slf4j/package-info.java | 30 --
.../java/org/slf4j/impl/StaticLoggerBinder.java | 84 -----
.../main/java/org/slf4j/impl/StaticMDCBinder.java | 60 ---
.../java/org/slf4j/impl/StaticMarkerBinder.java | 54 ---
.../src/main/java/org/slf4j/impl/package-info.java | 25 --
.../logging/other/pkg/LoggerContextAnchorTest.java | 91 -----
.../logging/slf4j/CallerInformationTest.java | 66 ----
.../org/apache/logging/slf4j/CustomFlatMarker.java | 74 ----
.../org/apache/logging/slf4j/Log4j1222Test.java | 53 ---
.../logging/slf4j/Log4j2_1482_Slf4jTest.java | 39 --
.../org/apache/logging/slf4j/Log4jMarkerTest.java | 46 ---
.../apache/logging/slf4j/LoggerContextTest.java | 43 ---
.../java/org/apache/logging/slf4j/LoggerTest.java | 171 ---------
.../java/org/apache/logging/slf4j/MarkerTest.java | 197 ----------
.../org/apache/logging/slf4j/OptionalTest.java | 69 ----
.../org/apache/logging/slf4j/OverflowTest.java | 41 ---
.../src/test/resources/log4j-test1.xml | 58 ---
.../src/test/resources/log4j2-1482.xml | 43 ---
log4j-slf4j2-impl/pom.xml | 158 --------
.../apache/logging/slf4j/Log4jEventBuilder.java | 163 ---------
.../java/org/apache/logging/slf4j/Log4jLogger.java | 402 ---------------------
.../apache/logging/slf4j/Log4jLoggerFactory.java | 71 ----
.../org/apache/logging/slf4j/Log4jMDCAdapter.java | 151 --------
.../java/org/apache/logging/slf4j/Log4jMarker.java | 126 -------
.../apache/logging/slf4j/Log4jMarkerFactory.java | 151 --------
.../logging/slf4j/SLF4JLoggingException.java | 41 ---
.../apache/logging/slf4j/SLF4JServiceProvider.java | 60 ---
.../org/apache/logging/slf4j/package-info.java | 30 --
.../services/org.slf4j.spi.SLF4JServiceProvider | 1 -
.../logging/other/pkg/LoggerContextAnchorTest.java | 91 -----
.../logging/slf4j/CallerInformationTest.java | 90 -----
.../org/apache/logging/slf4j/CustomFlatMarker.java | 74 ----
.../org/apache/logging/slf4j/Log4j1222Test.java | 53 ---
.../logging/slf4j/Log4j2_1482_Slf4jTest.java | 39 --
.../logging/slf4j/Log4jEventBuilderTest.java | 65 ----
.../apache/logging/slf4j/Log4jMDCAdapterTest.java | 61 ----
.../org/apache/logging/slf4j/Log4jMarkerTest.java | 46 ---
.../apache/logging/slf4j/LoggerContextTest.java | 43 ---
.../java/org/apache/logging/slf4j/LoggerTest.java | 206 -----------
.../java/org/apache/logging/slf4j/MarkerTest.java | 197 ----------
.../org/apache/logging/slf4j/OverflowTest.java | 41 ---
.../src/test/resources/log4j-test1.xml | 51 ---
.../src/test/resources/log4j2-1482.xml | 43 ---
.../src/test/resources/log4j2-config.xml | 37 --
log4j-spring-cloud-config-client/pom.xml | 8 +
log4j-to-jul/pom.xml | 75 ----
.../org/apache/logging/log4j/tojul/Activator.java | 30 --
.../org/apache/logging/log4j/tojul/JULLogger.java | 331 -----------------
.../logging/log4j/tojul/JULLoggerContext.java | 72 ----
.../log4j/tojul/JULLoggerContextFactory.java | 76 ----
.../apache/logging/log4j/tojul/JULProvider.java | 51 ---
.../logging/log4j/tojul/LazyLog4jLogRecord.java | 70 ----
.../apache/logging/log4j/tojul/package-info.java | 28 --
.../services/org.apache.logging.log4j.spi.Provider | 18 -
.../apache/logging/log4j/tojul/JULLoggerTest.java | 34 --
.../org/apache/logging/log4j/tojul/LoggerTest.java | 270 --------------
log4j-to-slf4j/pom.xml | 146 --------
.../java/org/apache/logging/slf4j/Activator.java | 31 --
.../org/apache/logging/slf4j/MDCContextMap.java | 107 ------
.../org/apache/logging/slf4j/SLF4JLogBuilder.java | 267 --------------
.../java/org/apache/logging/slf4j/SLF4JLogger.java | 381 -------------------
.../apache/logging/slf4j/SLF4JLoggerContext.java | 64 ----
.../logging/slf4j/SLF4JLoggerContextFactory.java | 69 ----
.../org/apache/logging/slf4j/SLF4JProvider.java | 49 ---
.../org/apache/logging/slf4j/package-info.java | 25 --
.../services/org.apache.logging.log4j.spi.Provider | 1 -
.../logging/slf4j/CallerInformationTest.java | 61 ----
.../apache/logging/slf4j/Log4j2Jira1688Test.java | 68 ----
.../org/apache/logging/slf4j/LogBuilderTest.java | 106 ------
.../logging/slf4j/LoggerContextResolver.java | 166 ---------
.../apache/logging/slf4j/LoggerContextSource.java | 52 ---
.../org/apache/logging/slf4j/LoggerResolver.java | 84 -----
.../java/org/apache/logging/slf4j/LoggerTest.java | 268 --------------
.../apache/logging/slf4j/MDCContextMapTest.java | 50 ---
.../java/org/apache/logging/slf4j/TestUtil.java | 47 ---
.../src/test/java/org/slf4j/MDCTestHelper.java | 28 --
.../apache/logging/slf4j/CallerInformationTest.xml | 38 --
.../org/apache/logging/slf4j/LogBuilderTest.xml | 39 --
.../org/apache/logging/slf4j/LoggerTest.xml | 29 --
pom.xml | 12 +-
src/site/antora/modules/ROOT/pages/components.adoc | 91 +----
.../modules/ROOT/pages/manual/installation.adoc | 12 +-
.../ROOT/partials/components/log4j-to-jul.adoc | 41 ---
.../ROOT/partials/components/log4j-to-slf4j.adoc | 41 ---
.../{components => features}/log4j-slf4j-impl.adoc | 0
.../log4j-slf4j2-impl.adoc | 0
99 files changed, 220 insertions(+), 8222 deletions(-)
diff --git a/log4j-core-test/pom.xml b/log4j-core-test/pom.xml
index ec83eae417..7489433380 100644
--- a/log4j-core-test/pom.xml
+++ b/log4j-core-test/pom.xml
@@ -70,188 +70,217 @@
<artifactId>org.osgi.framework</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.resource</artifactId>
<scope>provided</scope>
</dependency>
+
<!-- Naturally, all implementations require the log4j-api JAR -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
+
<!-- TEST DEPENDENCIES -->
<!-- Pull in useful test classes from API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api-test</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-plugins</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-plugins-test</artifactId>
</dependency>
+
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
+
<!-- Used for compressing to formats other than zip and gz -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<optional>true</optional>
</dependency>
+
<!-- Alternative implementation of BlockingQueue using Conversant Disruptor for AsyncAppender -->
<dependency>
<groupId>com.conversantmedia</groupId>
<artifactId>disruptor</artifactId>
<optional>true</optional>
</dependency>
+
<!-- Required for AsyncLoggers -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<optional>true</optional>
</dependency>
+
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
+
<!-- Required for JSON support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<optional>true</optional>
</dependency>
+
<!-- Required for JSON support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<optional>true</optional>
</dependency>
+
<!-- Required for XML layout and receiver support -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<optional>true</optional>
</dependency>
+
<!-- Required for YAML support (including JSON requirements) -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<optional>true</optional>
</dependency>
+
<!-- Required for console color support in Windows -->
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<optional>true</optional>
</dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
</dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
+
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<optional>true</optional>
</dependency>
+
<!-- JUnit, naturally -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
+
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Other -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.hdrhistogram</groupId>
<artifactId>HdrHistogram</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Embedded JDBC drivers for database appender tests -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Zeroconf advertiser tests -->
<dependency>
<groupId>org.jmdns</groupId>
<artifactId>jmdns</artifactId>
<scope>test</scope>
</dependency>
- <!-- Log4j 1.2 tests -->
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>com.github.ivandzf</groupId>
<artifactId>log4j2-custom-layout</artifactId>
<scope>test</scope>
</dependency>
+
<!-- For testing log4j 2 2.x plugins -->
<dependency>
<groupId>com.vlkan.log4j2</groupId>
<artifactId>log4j2-logstash-layout</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Mocking framework for use with JUnit -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-subclass</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
+
<!-- JEP-335 has deprecated the built-in JavaScript engine (Nashorn) in Java 11, and JEP-372 removed it in Java 15.
We are adding it back for tests that use JavaScript. -->
<dependency>
@@ -259,39 +288,39 @@
<artifactId>nashorn-core</artifactId>
<scope>test</scope>
</dependency>
- <!-- SLF4J tests -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Used for testing HTTP Watcher -->
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-matchers</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Apache Commons Compress -->
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<scope>test</scope>
</dependency>
+
</dependencies>
<build>
diff --git a/log4j-jndi-test/pom.xml b/log4j-jndi-test/pom.xml
index dbe975ee01..84959b9e1f 100644
--- a/log4j-jndi-test/pom.xml
+++ b/log4j-jndi-test/pom.xml
@@ -46,10 +46,6 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jndi</artifactId>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/log4j-mongodb/pom.xml b/log4j-mongodb/pom.xml
index 3ccd7f9df7..6c402d6528 100644
--- a/log4j-mongodb/pom.xml
+++ b/log4j-mongodb/pom.xml
@@ -35,29 +35,50 @@
~ OSGi and JPMS options
-->
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
+
+ <!-- Dependency versions -->
+ <slf4j2.version>2.0.16</slf4j2.version>
</properties>
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j2.version}</version>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
</dependency>
+
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api-test</artifactId>
@@ -69,6 +90,7 @@
</exclusion>
</exclusions>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core-test</artifactId>
@@ -88,31 +110,37 @@
</exclusion>
</exclusions>
</dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.process</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>de.flapdoodle.reverse</groupId>
<artifactId>de.flapdoodle.reverse</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
+
</dependencies>
<build>
@@ -126,16 +154,19 @@
<forkCount>1</forkCount>
</configuration>
<dependencies>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
+
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-nop</artifactId>
+ <artifactId>slf4j-simple</artifactId>
<version>${slf4j2.version}</version>
</dependency>
+
</dependencies>
</plugin>
diff --git a/log4j-osgi-test/pom.xml b/log4j-osgi-test/pom.xml
index ec386848a6..dded11ea81 100644
--- a/log4j-osgi-test/pom.xml
+++ b/log4j-osgi-test/pom.xml
@@ -40,100 +40,138 @@
<sign.skip>true</sign.skip>
<spotbugs.skip>true</spotbugs.skip>
- <spifly.version>1.3.7</spifly.version>
<!-- Fix the name of the package with `PluginService`, since it is also used in the code -->
<log4jPluginPackageForTests>org.apache.logging.log4j.osgi_test</log4jPluginPackageForTests>
+
+ <!-- Dependency versions -->
+ <spifly.version>1.3.7</spifly.version>
+ <logback.version>1.4.14</logback.version>
</properties>
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.spifly</groupId>
+ <artifactId>org.apache.aries.spifly.dynamic.bundle</artifactId>
+ <version>${spifly.version}</version>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
+
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api-test</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-plugins</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-jul</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.aries.spifly</groupId>
<artifactId>org.apache.aries.spifly.dynamic.bundle</artifactId>
- <version>${spifly.version}</version>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-assembly</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-spi</artifactId>
diff --git a/log4j-parent/pom.xml b/log4j-parent/pom.xml
index ca79e7308d..399082843d 100644
--- a/log4j-parent/pom.xml
+++ b/log4j-parent/pom.xml
@@ -102,7 +102,6 @@
<commons-dbcp2.version>2.12.0</commons-dbcp2.version>
<commons-io.version>2.16.1</commons-io.version>
<commons-lang3.version>3.17.0</commons-lang3.version>
- <commons-logging.version>1.3.4</commons-logging.version>
<conversant.disruptor.version>1.2.21</conversant.disruptor.version>
<disruptor.version>4.0.0</disruptor.version>
<elasticsearch.version>7.17.23</elasticsearch.version>
@@ -130,11 +129,9 @@
<junit.version>4.13.2</junit.version>
<junit-jupiter.version>5.10.3</junit-jupiter.version>
<junit-pioneer.version>2.2.0</junit-pioneer.version>
- <log4j.version>1.2.17</log4j.version>
<log4j2-custom-layout.version>1.1.0</log4j2-custom-layout.version>
<log4j2-ecs-layout.version>1.6.0</log4j2-ecs-layout.version>
<log4j2-logstash-layout.version>0.18</log4j2-logstash-layout.version>
- <logback.version>1.4.14</logback.version>
<maven.version>3.9.9</maven.version>
<mockito.version>5.13.0</mockito.version>
<mongodb.version>5.1.3</mongodb.version>
@@ -147,7 +144,6 @@
<osgi.resource.version>1.0.1</osgi.resource.version>
<pax-exam.version>4.13.5</pax-exam.version>
<plexus-utils.version>3.5.1</plexus-utils.version>
- <slf4j2.version>2.0.15</slf4j2.version>
<system-stubs.version>2.1.6</system-stubs.version>
<tomcat-juli.version>10.1.28</tomcat-juli.version>
<velocity.version>1.7</velocity.version>
@@ -312,12 +308,6 @@
<version>${commons-lang3.version}</version>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>${commons-logging.version}</version>
- </dependency>
-
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
@@ -485,12 +475,6 @@
<version>${junit-pioneer.version}</version>
</dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${log4j.version}</version>
- </dependency>
-
<!-- Tested as a legacy 2.x plugin: -->
<dependency>
<groupId>com.github.ivandzf</groupId>
@@ -518,32 +502,6 @@
<version>${log4j2-logstash-layout.version}</version>
</dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${logback.version}</version>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${logback.version}</version>
- <type>test-jar</type>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>${logback.version}</version>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>${logback.version}</version>
- <type>test-jar</type>
- </dependency>
-
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
@@ -646,12 +604,6 @@
<version>${plexus-utils.version}</version>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j2.version}</version>
- </dependency>
-
<dependency>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-core</artifactId>
diff --git a/log4j-perf-test/pom.xml b/log4j-perf-test/pom.xml
index 1be3e92ca3..fa7fb7f187 100644
--- a/log4j-perf-test/pom.xml
+++ b/log4j-perf-test/pom.xml
@@ -37,103 +37,159 @@
<bnd.baseline.skip>true</bnd.baseline.skip>
<maven.deploy.skip>true</maven.deploy.skip>
<module.name>org.apache.logging.log4j.perf</module.name>
+
+ <!-- Dependency versions -->
+ <reload4j.version>1.2.25</reload4j.version>
+ <logback.version>1.4.14</logback.version>
+ <slf4j2.version>2.0.16</slf4j2.version>
</properties>
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.reload4j</groupId>
+ <artifactId>reload4j</artifactId>
+ <version>${reload4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j2.version}</version>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
+
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-async-logger</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core-test</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jdbc</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-layout-template-json</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-layout-template-json-test</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-plugins</artifactId>
</dependency>
+
<dependency>
<groupId>com.conversantmedia</groupId>
<artifactId>disruptor</artifactId>
</dependency>
+
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
</dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
+
<!-- Embedded JDBC drivers for database appender tests -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
+
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<optional>true</optional>
</dependency>
+
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<optional>true</optional>
</dependency>
+
<dependency>
<groupId>org.jctools</groupId>
<artifactId>jctools-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
</dependency>
+
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
+ <groupId>ch.qos.reload4j</groupId>
+ <artifactId>reload4j</artifactId>
</dependency>
+
<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>log4j2-ecs-layout</artifactId>
</dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <scope>compile</scope>
</dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
- <scope>compile</scope>
</dependency>
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+
</dependencies>
<build>
@@ -166,6 +222,7 @@
<bannedDependencies>
<includes>
<include>ch.qos.logback:*</include>
+ <include>ch.qos.reload4j:*</include>
</includes>
</bannedDependencies>
</rules>
@@ -173,6 +230,7 @@
</execution>
</executions>
</plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@@ -189,6 +247,10 @@
<finalName>${uberjar.name}</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer" />
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/sisu/javax.inject.Named</resource>
+ </transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
<manifestEntries>
@@ -199,15 +261,28 @@
</transformers>
<filters>
<filter>
- <!--
- Shading signed JARs will fail without this.
- http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
- -->
<artifact>*:*</artifact>
<excludes>
+ <!-- These are removed anyway -->
+ <exclude>module-info.class</exclude>
+ <exclude>META-INF/versions/9/module-info.class</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
+ <!--
+ Shading signed JARs will fail without this.
+ http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
+ -->
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
+ <!-- We will use only Log4j Core 3 configuration property names -->
+ <exclude>META-INF/log4j/propertyMapping.json</exclude>
+ <!-- It is safe to remove licences and similar as long as we don't publish the artifact -->
+ <exclude>about.html</exclude>
+ <exclude>overview.html</exclude>
+ <exclude>META-INF/LICENSE-notice.md</exclude>
+ <exclude>LICENSE</exclude>
+ <!-- This JAR will not have any dependencies -->
+ <exclude>META-INF/DEPENDENCIES</exclude>
</excludes>
</filter>
</filters>
diff --git a/log4j-slf4j-impl/pom.xml b/log4j-slf4j-impl/pom.xml
deleted file mode 100644
index 81f71fc9c5..0000000000
--- a/log4j-slf4j-impl/pom.xml
+++ /dev/null
@@ -1,163 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${revision}</version>
- <relativePath>../log4j-parent</relativePath>
- </parent>
-
- <artifactId>log4j-slf4j-impl</artifactId>
-
- <name>SLF4J 1 Binding for Log4j API</name>
-
- <description>SLF4J 1 binding (provider) for the Log4j API.
- It forwards SLF4J 1 calls to the Log4j API.
- (Refer to the `log4j-to-slf4j` artifact for forwarding the Log4j API to SLF4J.)</description>
-
- <properties>
- <slf4j.version>1.7.36</slf4j.version>
- <bnd.baseline.skip>false</bnd.baseline.skip>
- </properties>
-
- <!-- Use explicit versions as a temporary workaround to a Coursier/Ivy bug:
- https://github.com/apache/logging-log4j2/issues/2065 -->
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.framework</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api-test</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-to-slf4j</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-csv</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>loop-test</id>
- <goals>
- <goal>test</goal>
- </goals>
- <phase>test</phase>
- <configuration>
- <includes>
- <include>**/OverflowTest.java</include>
- </includes>
- </configuration>
- </execution>
- <execution>
- <id>default-test</id>
- <goals>
- <goal>test</goal>
- </goals>
- <phase>test</phase>
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- <excludes>
- <exclude>**/OverflowTest.java</exclude>
- </excludes>
- <classpathDependencyExcludes>
- <classpathDependencyExcludes>org.apache.logging.log4j:log4j-to-slf4j</classpathDependencyExcludes>
- </classpathDependencyExcludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-</project>
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
deleted file mode 100644
index 4184874505..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.slf4j.Marker;
-import org.slf4j.spi.LocationAwareLogger;
-
-/**
- * SLF4J logger implementation that uses Log4j.
- */
-public class Log4jLogger implements LocationAwareLogger {
-
- public static final String FQCN = Log4jLogger.class.getName();
-
- private final ExtendedLogger logger;
- private final String name;
- private final Log4jMarkerFactory markerFactory;
-
- public Log4jLogger(final Log4jMarkerFactory markerFactory, final ExtendedLogger logger, final String name) {
- this.markerFactory = markerFactory;
- this.logger = logger;
- this.name = name;
- }
-
- @Override
- public void trace(final String format) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format);
- }
-
- @Override
- public void trace(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, o);
- }
-
- @Override
- public void trace(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, arg1, arg2);
- }
-
- @Override
- public void trace(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, args);
- }
-
- @Override
- public void trace(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, t);
- }
-
- @Override
- public boolean isTraceEnabled() {
- return logger.isEnabled(Level.TRACE, null, null);
- }
-
- @Override
- public boolean isTraceEnabled(final Marker marker) {
- return logger.isEnabled(Level.TRACE, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void trace(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void debug(final String format) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format);
- }
-
- @Override
- public void debug(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, o);
- }
-
- @Override
- public void debug(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, arg1, arg2);
- }
-
- @Override
- public void debug(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, args);
- }
-
- @Override
- public void debug(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, t);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return logger.isEnabled(Level.DEBUG, null, null);
- }
-
- @Override
- public boolean isDebugEnabled(final Marker marker) {
- return logger.isEnabled(Level.DEBUG, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void debug(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void info(final String format) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format);
- }
-
- @Override
- public void info(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, o);
- }
-
- @Override
- public void info(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, arg1, arg2);
- }
-
- @Override
- public void info(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, args);
- }
-
- @Override
- public void info(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, t);
- }
-
- @Override
- public boolean isInfoEnabled() {
- return logger.isEnabled(Level.INFO, null, null);
- }
-
- @Override
- public boolean isInfoEnabled(final Marker marker) {
- return logger.isEnabled(Level.INFO, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void info(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void warn(final String format) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format);
- }
-
- @Override
- public void warn(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, o);
- }
-
- @Override
- public void warn(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, arg1, arg2);
- }
-
- @Override
- public void warn(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, args);
- }
-
- @Override
- public void warn(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, t);
- }
-
- @Override
- public boolean isWarnEnabled() {
- return logger.isEnabled(Level.WARN, null, null);
- }
-
- @Override
- public boolean isWarnEnabled(final Marker marker) {
- return logger.isEnabled(Level.WARN, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void warn(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void error(final String format) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format);
- }
-
- @Override
- public void error(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, o);
- }
-
- @Override
- public void error(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, arg1, arg2);
- }
-
- @Override
- public void error(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, args);
- }
-
- @Override
- public void error(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, t);
- }
-
- @Override
- public boolean isErrorEnabled() {
- return logger.isEnabled(Level.ERROR, null, null);
- }
-
- @Override
- public boolean isErrorEnabled(final Marker marker) {
- return logger.isEnabled(Level.ERROR, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void error(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void log(
- final Marker marker,
- final String fqcn,
- final int level,
- final String message,
- final Object[] params,
- final Throwable throwable) {
- final Level log4jLevel = getLevel(level);
- final org.apache.logging.log4j.Marker log4jMarker = markerFactory.getLog4jMarker(marker);
-
- if (!logger.isEnabled(log4jLevel, log4jMarker, message, params)) {
- return;
- }
- final Message msg;
- final Throwable actualThrowable;
- if (params == null) {
- msg = new SimpleMessage(message);
- actualThrowable = throwable;
- } else {
- msg = new ParameterizedMessage(message, params, throwable);
- actualThrowable = throwable != null ? throwable : msg.getThrowable();
- }
- logger.logMessage(fqcn, log4jLevel, log4jMarker, msg, actualThrowable);
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- private static Level getLevel(final int i) {
- switch (i) {
- case TRACE_INT:
- return Level.TRACE;
- case DEBUG_INT:
- return Level.DEBUG;
- case INFO_INT:
- return Level.INFO;
- case WARN_INT:
- return Level.WARN;
- case ERROR_INT:
- return Level.ERROR;
- }
- return Level.ERROR;
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
deleted file mode 100644
index 0f3eded7a8..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.function.Predicate;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.spi.AbstractLoggerAdapter;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.StackLocatorUtil;
-import org.slf4j.ILoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * Log4j implementation of SLF4J ILoggerFactory interface.
- */
-public class Log4jLoggerFactory extends AbstractLoggerAdapter<Logger> implements ILoggerFactory {
-
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
- private static final String SLF4J_PACKAGE = "org.slf4j";
- private static final Predicate<Class<?>> CALLER_PREDICATE = clazz ->
- !AbstractLoggerAdapter.class.equals(clazz) && !clazz.getName().startsWith(SLF4J_PACKAGE);
- private static final String TO_SLF4J_CONTEXT = "org.apache.logging.slf4j.SLF4JLoggerContext";
-
- private final Log4jMarkerFactory markerFactory;
-
- public Log4jLoggerFactory(final Log4jMarkerFactory markerFactory) {
- this.markerFactory = markerFactory;
- }
-
- @Override
- protected Logger newLogger(final String name, final LoggerContext context) {
- final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
- return new Log4jLogger(markerFactory, validateContext(context).getLogger(key), name);
- }
-
- @Override
- protected LoggerContext getContext() {
- final Class<?> anchor = LogManager.getFactory().isClassLoaderDependent()
- ? StackLocatorUtil.getCallerClass(Log4jLoggerFactory.class, CALLER_PREDICATE)
- : null;
- LOGGER.trace("Log4jLoggerFactory.getContext() found anchor {}", anchor);
- return anchor == null ? LogManager.getContext(false) : getContext(anchor);
- }
-
- Log4jMarkerFactory getMarkerFactory() {
- return markerFactory;
- }
-
- private LoggerContext validateContext(final LoggerContext context) {
- if (TO_SLF4J_CONTEXT.equals(context.getClass().getName())) {
- throw new LoggingException("log4j-slf4j-impl cannot be present with log4j-to-slf4j");
- }
- return context;
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java
deleted file mode 100644
index a32c9c7779..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.Map;
-import org.apache.logging.log4j.ThreadContext;
-import org.slf4j.spi.MDCAdapter;
-
-/**
- *
- */
-public class Log4jMDCAdapter implements MDCAdapter {
-
- @Override
- public void put(final String key, final String val) {
- ThreadContext.put(key, val);
- }
-
- @Override
- public String get(final String key) {
- return ThreadContext.get(key);
- }
-
- @Override
- public void remove(final String key) {
- ThreadContext.remove(key);
- }
-
- @Override
- public void clear() {
- ThreadContext.clearMap();
- }
-
- @Override
- public Map<String, String> getCopyOfContextMap() {
- return ThreadContext.getContext();
- }
-
- @Override
- public void setContextMap(final Map<String, String> map) {
- ThreadContext.clearMap();
- ThreadContext.putAll(map);
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java
deleted file mode 100644
index e2fbe62491..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import org.apache.logging.log4j.MarkerManager;
-import org.slf4j.IMarkerFactory;
-import org.slf4j.Marker;
-
-/**
- * Log4j/SLF4J {@link Marker} type bridge.
- */
-class Log4jMarker implements Marker {
-
- public static final long serialVersionUID = 1590472L;
-
- private final IMarkerFactory factory;
-
- private final org.apache.logging.log4j.Marker marker;
-
- /**
- * Constructs a Log4jMarker using an existing Log4j {@link org.apache.logging.log4j.Marker}.
- * @param marker The Log4j Marker upon which to base this Marker.
- */
- public Log4jMarker(final IMarkerFactory markerFactory, final org.apache.logging.log4j.Marker marker) {
- this.factory = markerFactory;
- this.marker = marker;
- }
-
- @Override
- public void add(final Marker marker) {
- if (marker == null) {
- throw new IllegalArgumentException();
- }
- final Marker m = factory.getMarker(marker.getName());
- this.marker.addParents(((Log4jMarker) m).getLog4jMarker());
- }
-
- @Override
- public boolean contains(final Marker marker) {
- if (marker == null) {
- throw new IllegalArgumentException();
- }
- return this.marker.isInstanceOf(marker.getName());
- }
-
- @Override
- public boolean contains(final String s) {
- return s != null ? this.marker.isInstanceOf(s) : false;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Log4jMarker)) {
- return false;
- }
- final Log4jMarker other = (Log4jMarker) obj;
- return Objects.equals(marker, other.marker);
- }
-
- public org.apache.logging.log4j.Marker getLog4jMarker() {
- return marker;
- }
-
- @Override
- public String getName() {
- return marker.getName();
- }
-
- @Override
- public boolean hasChildren() {
- return marker.hasParents();
- }
-
- @Override
- public int hashCode() {
- return 31 + Objects.hashCode(marker);
- }
-
- @Override
- public boolean hasReferences() {
- return marker.hasParents();
- }
-
- @Override
- public Iterator<Marker> iterator() {
- final org.apache.logging.log4j.Marker[] log4jParents = this.marker.getParents();
- if (log4jParents == null) {
- return Collections.emptyIterator();
- }
- final List<Marker> parents = new ArrayList<>(log4jParents.length);
- for (final org.apache.logging.log4j.Marker m : log4jParents) {
- parents.add(factory.getMarker(m.getName()));
- }
- return parents.iterator();
- }
-
- @Override
- public boolean remove(final Marker marker) {
- return marker != null ? this.marker.remove(MarkerManager.getMarker(marker.getName())) : false;
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java
deleted file mode 100644
index cedfc06571..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.slf4j.IMarkerFactory;
-import org.slf4j.Marker;
-
-/**
- * Log4j/SLF4J bridge to create SLF4J Markers based on name or based on existing SLF4J Markers.
- */
-public class Log4jMarkerFactory implements IMarkerFactory {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<>();
-
- /**
- * Returns a Log4j Marker that is compatible with SLF4J.
- * @param name The name of the Marker.
- * @return A Marker.
- */
- @Override
- public Marker getMarker(final String name) {
- if (name == null) {
- throw new IllegalArgumentException("Marker name must not be null");
- }
- final Marker marker = markerMap.get(name);
- if (marker != null) {
- return marker;
- }
- final org.apache.logging.log4j.Marker log4jMarker = MarkerManager.getMarker(name);
- return addMarkerIfAbsent(name, log4jMarker);
- }
-
- private Marker addMarkerIfAbsent(final String name, final org.apache.logging.log4j.Marker log4jMarker) {
- final Marker marker = new Log4jMarker(this, log4jMarker);
- final Marker existing = markerMap.putIfAbsent(name, marker);
- return existing == null ? marker : existing;
- }
-
- /**
- * Returns a Log4j Marker converted from an existing custom SLF4J Marker.
- * @param marker The SLF4J Marker to convert.
- * @return A converted Log4j/SLF4J Marker.
- * @since 2.1
- */
- public Marker getMarker(final Marker marker) {
- if (marker == null) {
- throw new IllegalArgumentException("Marker must not be null");
- }
- final Marker m = markerMap.get(marker.getName());
- if (m != null) {
- return m;
- }
- return addMarkerIfAbsent(marker.getName(), convertMarker(marker));
- }
-
- /**
- * Gets the Log4j2 marker associated to this SLF4J marker or creates a new one.
- *
- * @param marker a SLF4J marker
- * @return a Log4j2 marker
- */
- org.apache.logging.log4j.Marker getLog4jMarker(final Marker marker) {
- if (marker == null) {
- return null;
- } else if (marker instanceof Log4jMarker) {
- return ((Log4jMarker) marker).getLog4jMarker();
- } else {
- return ((Log4jMarker) getMarker(marker)).getLog4jMarker();
- }
- }
-
- static org.apache.logging.log4j.Marker convertMarker(final Marker original) {
- if (original == null) {
- throw new IllegalArgumentException("Marker must not be null");
- }
- return convertMarker(original, new ArrayList<Marker>());
- }
-
- private static org.apache.logging.log4j.Marker convertMarker(
- final Marker original, final Collection<Marker> visited) {
- final org.apache.logging.log4j.Marker marker = MarkerManager.getMarker(original.getName());
- if (original.hasReferences()) {
- final Iterator<Marker> it = original.iterator();
- while (it.hasNext()) {
- final Marker next = it.next();
- if (visited.contains(next)) {
- LOGGER.warn("Found a cycle in Marker [{}]. Cycle will be broken.", next.getName());
- } else {
- visited.add(next);
- marker.addParents(convertMarker(next, visited));
- }
- }
- }
- return marker;
- }
-
- /**
- * Returns true if the Marker exists.
- * @param name The Marker name.
- * @return {@code true} if the Marker exists, {@code false} otherwise.
- */
- @Override
- public boolean exists(final String name) {
- return markerMap.containsKey(name);
- }
-
- /**
- * Log4j does not support detached Markers. This method always returns false.
- * @param name The Marker name.
- * @return {@code false}
- */
- @Override
- public boolean detachMarker(final String name) {
- return false;
- }
-
- /**
- * Log4j does not support detached Markers for performance reasons. The returned Marker is attached.
- * @param name The Marker name.
- * @return The named Marker (unmodified).
- */
- @Override
- public Marker getDetachedMarker(final String name) {
- LOGGER.warn("Log4j does not support detached Markers. Returned Marker [{}] will be unchanged.", name);
- return getMarker(name);
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java
deleted file mode 100644
index 57a65e1dfb..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-/**
- * Exception thrown when the SLF4J adapter encounters a problem.
- *
- */
-public class SLF4JLoggingException extends RuntimeException {
-
- /**
- * Generated serial version ID.
- */
- private static final long serialVersionUID = -1618650972455089998L;
-
- public SLF4JLoggingException(final String msg) {
- super(msg);
- }
-
- public SLF4JLoggingException(final String msg, final Exception ex) {
- super(msg, ex);
- }
-
- public SLF4JLoggingException(final Exception ex) {
- super(ex);
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/package-info.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/package-info.java
deleted file mode 100644
index d847bc764b..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * SLF4J support. Note that this does indeed share the same package namespace as the one found in log4j-to-slf4j;
- * this is intentional. The two JARs should <em>not</em> be used at the same time! Thus, in an OSGi environment
- * where split packages are not allowed, this error is prevented due to both JARs sharing an exported package name.
- */
-@Export
-@Header(name = Constants.BUNDLE_ACTIVATIONPOLICY, value = Constants.ACTIVATION_LAZY)
-@Version("3.0.0")
-package org.apache.logging.slf4j;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.bundle.Header;
-import org.osgi.annotation.versioning.Version;
-import org.osgi.framework.Constants;
diff --git a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
deleted file mode 100644
index c60fac542d..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.slf4j.impl;
-
-import org.apache.logging.slf4j.Log4jLoggerFactory;
-import org.apache.logging.slf4j.Log4jMarkerFactory;
-import org.slf4j.ILoggerFactory;
-import org.slf4j.spi.LoggerFactoryBinder;
-
-/**
- * SLF4J LoggerFactoryBinder implementation using Log4j. This class is part of the required classes used to specify an
- * SLF4J logger provider implementation.
- */
-public final class StaticLoggerBinder implements LoggerFactoryBinder {
-
- /**
- * Declare the version of the SLF4J API this implementation is compiled
- * against. The value of this field is usually modified with each release.
- */
- // to avoid constant folding by the compiler, this field must *not* be final
- public static String REQUESTED_API_VERSION = "1.6"; // !final
-
- private static final String LOGGER_FACTORY_CLASS_STR = Log4jLoggerFactory.class.getName();
-
- /**
- * The unique instance of this class.
- */
- private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
-
- /**
- * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
- * method should always be the same object
- */
- private final ILoggerFactory loggerFactory;
-
- /**
- * Private constructor to prevent instantiation
- */
- private StaticLoggerBinder() {
- loggerFactory = new Log4jLoggerFactory(
- (Log4jMarkerFactory) StaticMarkerBinder.getSingleton().getMarkerFactory());
- }
-
- /**
- * Returns the singleton of this class.
- *
- * @return the StaticLoggerBinder singleton
- */
- public static StaticLoggerBinder getSingleton() {
- return SINGLETON;
- }
-
- /**
- * Returns the factory.
- * @return the factor.
- */
- @Override
- public ILoggerFactory getLoggerFactory() {
- return loggerFactory;
- }
-
- /**
- * Returns the class name.
- * @return the class name;
- */
- @Override
- public String getLoggerFactoryClassStr() {
- return LOGGER_FACTORY_CLASS_STR;
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java
deleted file mode 100644
index abe3fbb6b6..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.slf4j.impl;
-
-import org.apache.logging.slf4j.Log4jMDCAdapter;
-import org.slf4j.spi.MDCAdapter;
-
-/**
- *
- */
-public final class StaticMDCBinder {
-
- /**
- * The unique instance of this class.
- */
- public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
-
- private final MDCAdapter mdcAdapter = new Log4jMDCAdapter();
-
- private StaticMDCBinder() {}
-
- /**
- * Returns the {@link #SINGLETON} {@link StaticMDCBinder}.
- * Added to slf4j-api 1.7.14 via https://github.com/qos-ch/slf4j/commit/ea3cca72cd5a9329a06b788317a17e806ee8acd0
- * @return the singleton instance
- */
- public static StaticMDCBinder getSingleton() {
- return SINGLETON;
- }
-
- /**
- * Currently this method always returns an instance of {@link StaticMDCBinder}.
- * @return an MDC adapter
- */
- public MDCAdapter getMDCA() {
- return mdcAdapter;
- }
-
- /**
- * Retrieve the adapter class name.
- * @return The adapter class name.
- */
- public String getMDCAdapterClassStr() {
- return Log4jMDCAdapter.class.getName();
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
deleted file mode 100644
index d295d1016e..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.slf4j.impl;
-
-import org.apache.logging.slf4j.Log4jMarkerFactory;
-import org.slf4j.IMarkerFactory;
-import org.slf4j.spi.MarkerFactoryBinder;
-
-/**
- * SLF4J MarkerFactoryBinder implementation using Log4j. This class is part of the required classes used to specify an
- * SLF4J logging provider implementation.
- */
-public class StaticMarkerBinder implements MarkerFactoryBinder {
-
- /**
- * The unique instance of this class.
- */
- public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
-
- private final IMarkerFactory markerFactory = new Log4jMarkerFactory();
-
- /**
- * Returns the {@link #SINGLETON} {@link StaticMarkerBinder}.
- * Added to slf4j-api 1.7.14 via https://github.com/qos-ch/slf4j/commit/ea3cca72cd5a9329a06b788317a17e806ee8acd0
- * @return the singleton instance
- */
- public static StaticMarkerBinder getSingleton() {
- return SINGLETON;
- }
-
- @Override
- public IMarkerFactory getMarkerFactory() {
- return markerFactory;
- }
-
- @Override
- public String getMarkerFactoryClassStr() {
- return Log4jMarkerFactory.class.getName();
- }
-}
diff --git a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/package-info.java b/log4j-slf4j-impl/src/main/java/org/slf4j/impl/package-info.java
deleted file mode 100644
index aaa5b26903..0000000000
--- a/log4j-slf4j-impl/src/main/java/org/slf4j/impl/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Log4j 2.0 SLF4J Binding.
- */
-@Export
-@Version("2.20.1")
-package org.slf4j.impl;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/other/pkg/LoggerContextAnchorTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/other/pkg/LoggerContextAnchorTest.java
deleted file mode 100644
index 5732c205a4..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/other/pkg/LoggerContextAnchorTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.other.pkg;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.status.StatusData;
-import org.apache.logging.log4j.status.StatusListener;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.Test;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test LoggerContext lookups by verifying the anchor class representing calling code.
- */
-public class LoggerContextAnchorTest {
- private static final String PREFIX = "Log4jLoggerFactory.getContext() found anchor class ";
-
- @Test
- public void testLoggerFactoryLookupClass() {
- final String fqcn = getAnchorFqcn(() -> LoggerFactory.getLogger(LoggerContextAnchorTest.class));
- assertEquals(getClass().getName(), fqcn);
- }
-
- @Test
- public void testLoggerFactoryLookupString() {
- final String fqcn = getAnchorFqcn(() -> LoggerFactory.getLogger("custom.logger"));
- assertEquals(getClass().getName(), fqcn);
- }
-
- @Test
- public void testLoggerFactoryGetILoggerFactoryLookup() {
- final String fqcn =
- getAnchorFqcn(() -> LoggerFactory.getILoggerFactory().getLogger("custom.logger"));
- assertEquals(getClass().getName(), fqcn);
- }
-
- private static String getAnchorFqcn(final Runnable runnable) {
- final List<String> results = new CopyOnWriteArrayList<>();
- final StatusListener listener = new StatusListener() {
- @Override
- public void log(final StatusData data) {
- final String formattedMessage = data.getMessage().getFormattedMessage();
- if (formattedMessage.startsWith(PREFIX)) {
- results.add(formattedMessage.substring(PREFIX.length()));
- }
- }
-
- @Override
- public Level getStatusLevel() {
- return Level.TRACE;
- }
-
- @Override
- public void close() {
- // nop
- }
- };
- final StatusLogger statusLogger = StatusLogger.getLogger();
- statusLogger.registerListener(listener);
- try {
- runnable.run();
- if (results.isEmpty()) {
- throw new AssertionError("Failed to locate an anchor lookup status message");
- }
- if (results.size() > 1) {
- throw new AssertionError("Found multiple anchor lines: " + results);
- }
- return results.get(0);
- } finally {
- statusLogger.removeListener(listener);
- }
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
deleted file mode 100644
index efcce8b2ad..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CallerInformationTest {
-
- // config from log4j-core test-jar
- private static final String CONFIG = "log4j2-calling-class.xml";
-
- @ClassRule
- public static final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
-
- @Test
- public void testClassLogger() throws Exception {
- final ListAppender app = ctx.getListAppender("Class").clear();
- final Logger logger = LoggerFactory.getLogger("ClassLogger");
- logger.info("Ignored message contents.");
- logger.warn("Verifying the caller class is still correct.");
- logger.error("Hopefully nobody breaks me!");
- final List<String> messages = app.getMessages();
- assertEquals("Incorrect number of messages.", 3, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
- }
- }
-
- @Test
- public void testMethodLogger() throws Exception {
- final ListAppender app = ctx.getListAppender("Method").clear();
- final Logger logger = LoggerFactory.getLogger("MethodLogger");
- logger.info("More messages.");
- logger.warn("CATASTROPHE INCOMING!");
- logger.error("ZOMBIES!!!");
- logger.warn("brains~~~");
- logger.info("Itchy. Tasty.");
- final List<String> messages = app.getMessages();
- assertEquals("Incorrect number of messages.", 5, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller method name.", "testMethodLogger", message);
- }
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CustomFlatMarker.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CustomFlatMarker.java
deleted file mode 100644
index 3d82209728..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CustomFlatMarker.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.Iterator;
-import org.slf4j.Marker;
-
-/**
- * Test Marker that may contain no reference/parent Markers.
- * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-793">LOG4J2-793</a>
- */
-public class CustomFlatMarker implements Marker {
- private static final long serialVersionUID = -4115520883240247266L;
-
- private final String name;
-
- public CustomFlatMarker(final String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void add(final Marker reference) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean remove(final Marker reference) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean hasChildren() {
- return hasReferences();
- }
-
- @Override
- public boolean hasReferences() {
- return false;
- }
-
- @Override
- public Iterator<Marker> iterator() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean contains(final Marker other) {
- return false;
- }
-
- @Override
- public boolean contains(final String name) {
- return false;
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j1222Test.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j1222Test.java
deleted file mode 100644
index 85d9d0dff4..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j1222Test.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests logging during shutdown.
- */
-public class Log4j1222Test {
-
- @Test
- public void homepageRendersSuccessfully() {
- System.setProperty("log4j.configurationFile", "log4j2-console.xml");
- Runtime.getRuntime().addShutdownHook(new ShutdownHook());
- }
-
- private static class ShutdownHook extends Thread {
-
- private static class Holder {
- private static final Logger LOGGER = LoggerFactory.getLogger(Log4j1222Test.class);
- }
-
- @Override
- public void run() {
- super.run();
- trigger();
- }
-
- private void trigger() {
- Holder.LOGGER.info("Attempt to trigger");
- assertTrue("Logger is of type " + Holder.LOGGER.getClass().getName(), Holder.LOGGER instanceof Log4jLogger);
- }
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java
deleted file mode 100644
index d8abaf65a4..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.core.test.layout.Log4j2_1482_Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests https://issues.apache.org/jira/browse/LOG4J2-1482
- */
-public class Log4j2_1482_Slf4jTest extends Log4j2_1482_Test {
-
- @Override
- protected void log(final int runNumber) {
- if (runNumber == 2) {
- // System.out.println("Set a breakpoint here.");
- }
- final Logger logger = LoggerFactory.getLogger("auditcsvfile");
- final int val1 = 9, val2 = 11, val3 = 12;
- logger.info("Info Message!", val1, val2, val3);
- logger.info("Info Message!", val1, val2, val3);
- logger.info("Info Message!", val1, val2, val3);
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4jMarkerTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4jMarkerTest.java
deleted file mode 100644
index 837b392a69..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4jMarkerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class Log4jMarkerTest {
-
- private static Log4jMarkerFactory markerFactory;
-
- @BeforeClass
- public static void startup() {
- markerFactory = ((Log4jLoggerFactory) org.slf4j.LoggerFactory.getILoggerFactory()).getMarkerFactory();
- }
-
- @Test
- public void testEquals() {
- final Marker markerA = MarkerManager.getMarker(Log4jMarkerTest.class.getName() + "-A");
- final Marker markerB = MarkerManager.getMarker(Log4jMarkerTest.class.getName() + "-B");
- final Log4jMarker marker1 = new Log4jMarker(markerFactory, markerA);
- final Log4jMarker marker2 = new Log4jMarker(markerFactory, markerA);
- final Log4jMarker marker3 = new Log4jMarker(markerFactory, markerB);
- Assert.assertEquals(marker1, marker2);
- Assert.assertNotEquals(marker1, null);
- Assert.assertNotEquals(null, marker1);
- Assert.assertNotEquals(marker1, marker3);
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerContextTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerContextTest.java
deleted file mode 100644
index d77e1d4d34..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerContextTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-import org.apache.logging.log4j.core.LifeCycle;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.junit.Test;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests cleanup of the LoggerContexts.
- */
-public class LoggerContextTest {
-
- @Test
- public void testCleanup() throws Exception {
- final Log4jLoggerFactory factory = (Log4jLoggerFactory) LoggerFactory.getILoggerFactory();
- factory.getLogger("test");
- Set<LoggerContext> set = factory.getLoggerContexts();
- final LoggerContext ctx1 = set.toArray(LoggerContext.EMPTY_ARRAY)[0];
- assertTrue("LoggerContext is not enabled for shutdown", ctx1 instanceof LifeCycle);
- ((LifeCycle) ctx1).stop();
- set = factory.getLoggerContexts();
- assertTrue("Expected no LoggerContexts", set.isEmpty());
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
deleted file mode 100644
index c1fc9a7841..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.List;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.apache.logging.log4j.util.Strings;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.spi.LocationAwareLogger;
-
-/**
- *
- */
-public class LoggerTest {
-
- private static final String CONFIG = "log4j-test1.xml";
-
- @ClassRule
- public static LoggerContextRule ctx = new LoggerContextRule(CONFIG);
-
- Logger logger = LoggerFactory.getLogger("LoggerTest");
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void debugNoParms() {
- logger.debug("Debug message {}");
- verify("o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
- logger.debug("Debug message {}", (Object[]) null);
- verify("o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
- ((LocationAwareLogger) logger)
- .log(null, Log4jLogger.class.getName(), LocationAwareLogger.DEBUG_INT, "Debug message {}", null, null);
- verify("o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- verify("o.a.l.s.LoggerTest Hello, World MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void mdc() {
-
- MDC.put("TestYear", "2010");
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Strings.LINE_SEPARATOR);
- MDC.clear();
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- /**
- * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-793">LOG4J2-793</a>
- */
- @Test
- public void supportsCustomSLF4JMarkers() {
- final Marker marker = new CustomFlatMarker("TEST");
- logger.debug(marker, "Test");
- verify("o.a.l.s.LoggerTest Test MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void testRootLogger() {
- final Logger l = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
- assertNotNull("No Root Logger", l);
- assertEquals(Logger.ROOT_LOGGER_NAME, l.getName());
- }
-
- @Test
- public void doubleSubst() {
- logger.debug("Hello, {}", "Log4j {}");
- verify("o.a.l.s.LoggerTest Hello, Log4j {} MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void testThrowable() {
- final Throwable expected = new RuntimeException();
- logger.debug("Hello {}", expected);
- verifyThrowable(expected);
- logger.debug("Hello {}", (Object) expected);
- verifyThrowable(null);
- logger.debug("Hello", expected);
- verifyThrowable(expected);
- logger.debug("Hello {}! {}", "World!", expected);
- verifyThrowable(null);
- logger.debug("Hello {}!", "World!", expected);
- verifyThrowable(expected);
- final LocationAwareLogger lal = (LocationAwareLogger) logger;
- lal.log(null, LoggerTest.class.getName(), LocationAwareLogger.DEBUG_INT, "Hello {}", null, expected);
- verifyThrowable(expected);
- lal.log(
- null,
- LoggerTest.class.getName(),
- LocationAwareLogger.DEBUG_INT,
- "Hello {}",
- new Object[] {expected},
- null);
- verifyThrowable(null);
- lal.log(
- null,
- LoggerTest.class.getName(),
- LocationAwareLogger.DEBUG_INT,
- "Hello {}",
- new Object[] {"World!", expected},
- null);
- verifyThrowable(expected);
- }
-
- private ListAppender getAppenderByName(final String name) {
- final ListAppender listApp = ctx.getListAppender(name);
- assertNotNull("Missing Appender", listApp);
- return listApp;
- }
-
- private void verify(final String expected) {
- final ListAppender listApp = getAppenderByName("List");
- final List<String> events = listApp.getMessages();
- assertEquals("Incorrect number of messages. Expected 1 Actual " + events.size(), 1, events.size());
- final String actual = events.get(0);
- assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
- listApp.clear();
- }
-
- private void verifyThrowable(final Throwable expected) {
- final ListAppender listApp = getAppenderByName("UnformattedList");
- final List<LogEvent> events = listApp.getEvents();
- assertEquals("Incorrect number of messages", 1, events.size());
- final LogEvent actual = events.get(0);
- assertEquals("Incorrect throwable.", expected, actual.getThrown());
- listApp.clear();
- }
-
- @Before
- @After
- public void cleanup() {
- MDC.clear();
- ctx.getListAppender("List").clear();
- ctx.getListAppender("UnformattedList").clear();
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java
deleted file mode 100644
index 0db3e30393..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- */
-public class MarkerTest {
-
- private static final String CHILD_MAKER_NAME = MarkerTest.class.getSimpleName() + "-TEST";
- private static final String PARENT_MARKER_NAME = MarkerTest.class.getSimpleName() + "-PARENT";
- private static Log4jMarkerFactory markerFactory;
-
- @BeforeClass
- public static void startup() {
- markerFactory = ((Log4jLoggerFactory) org.slf4j.LoggerFactory.getILoggerFactory()).getMarkerFactory();
- }
-
- @Before
- @After
- public void clearMarkers() {
- MarkerManager.clear();
- }
-
- @Test
- public void testAddMarker() {
- final String childMakerName = CHILD_MAKER_NAME + "-AM";
- final String parentMarkerName = PARENT_MARKER_NAME + "-AM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMakerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMarkerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMarkerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMakerName);
-
- assertTrue("Incorrect Marker class", slf4jMarker instanceof Log4jMarker);
- assertTrue(
- String.format(
- "%s (log4jMarker=%s) is not an instance of %s (log4jParent=%s) in Log4j",
- childMakerName, parentMarkerName, log4jMarker, log4jParent),
- log4jMarker.isInstanceOf(log4jParent));
- assertTrue(
- String.format(
- "%s (slf4jMarker=%s) is not an instance of %s (log4jParent=%s) in SLF4J",
- childMakerName, parentMarkerName, slf4jMarker, slf4jParent),
- slf4jMarker.contains(slf4jParent));
- }
-
- @Test
- public void testAddNullMarker() {
- final String childMarkerName = CHILD_MAKER_NAME + "-ANM";
- final String parentMakerName = PARENT_MARKER_NAME + "-ANM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final org.slf4j.Marker nullMarker = null;
- try {
- log4jSlf4jParent.add(nullMarker);
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- try {
- log4jSlf4jMarker.add(nullMarker);
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- }
-
- @Test
- public void testAddSameMarker() {
- final String childMarkerName = CHILD_MAKER_NAME + "-ASM";
- final String parentMakerName = PARENT_MARKER_NAME + "-ASM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- assertTrue(
- String.format(
- "%s (log4jMarker=%s) is not an instance of %s (log4jParent=%s) in Log4j",
- childMarkerName, parentMakerName, log4jMarker, log4jParent),
- log4jMarker.isInstanceOf(log4jParent));
- assertTrue(
- String.format(
- "%s (slf4jMarker=%s) is not an instance of %s (log4jParent=%s) in SLF4J",
- childMarkerName, parentMakerName, slf4jMarker, slf4jParent),
- slf4jMarker.contains(slf4jParent));
- }
-
- @Test
- public void testEquals() {
- final String childMarkerName = CHILD_MAKER_NAME + "-ASM";
- final String parentMakerName = PARENT_MARKER_NAME + "-ASM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jMarker2 = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Marker log4jMarker2 = MarkerManager.getMarker(childMarkerName);
- assertEquals(log4jMarker, log4jMarker2);
- assertEquals(slf4jMarker, slf4jMarker2);
- assertNotEquals(log4jParent, log4jMarker);
- assertNotEquals(slf4jParent, slf4jMarker);
- }
-
- @Test
- public void testContainsNullMarker() {
- final String childMarkerName = CHILD_MAKER_NAME + "-CM";
- final String parentMakerName = PARENT_MARKER_NAME + "-CM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final org.slf4j.Marker nullMarker = null;
- try {
- Assert.assertFalse(log4jSlf4jParent.contains(nullMarker));
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- try {
- Assert.assertFalse(log4jSlf4jMarker.contains(nullMarker));
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- }
-
- @Test
- public void testContainsNullString() {
- final String childMarkerName = CHILD_MAKER_NAME + "-CS";
- final String parentMakerName = PARENT_MARKER_NAME + "-CS";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final String nullStr = null;
- Assert.assertFalse(log4jSlf4jParent.contains(nullStr));
- Assert.assertFalse(log4jSlf4jMarker.contains(nullStr));
- }
-
- @Test
- public void testRemoveNullMarker() {
- final String childMakerName = CHILD_MAKER_NAME + "-CM";
- final String parentMakerName = PARENT_MARKER_NAME + "-CM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMakerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMakerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final org.slf4j.Marker nullMarker = null;
- Assert.assertFalse(log4jSlf4jParent.remove(nullMarker));
- Assert.assertFalse(log4jSlf4jMarker.remove(nullMarker));
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
deleted file mode 100644
index f56cd9435d..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.apache.logging.log4j.util.Strings;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-
-/**
- *
- */
-public class OptionalTest {
-
- private static final String CONFIG = "log4j-test1.xml";
-
- @ClassRule
- public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG);
-
- Logger logger = LoggerFactory.getLogger("EventLogger");
- Marker marker = MarkerFactory.getMarker("EVENT");
-
- @Test
- public void testEventLogger() {
- logger.info(marker, "This is a test");
- MDC.clear();
- verify("EventLogger", "o.a.l.s.OptionalTest This is a test" + Strings.LINE_SEPARATOR);
- }
-
- private void verify(final String name, final String expected) {
- final ListAppender listApp = CTX.getListAppender(name);
- final List<String> events = listApp.getMessages();
- assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size() == 1);
- final String actual = events.get(0);
- assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
- listApp.clear();
- }
-
- @Before
- public void cleanup() {
- CTX.getListAppender("List").clear();
- CTX.getListAppender("EventLogger").clear();
- }
-}
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OverflowTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OverflowTest.java
deleted file mode 100644
index a0e5b0001a..0000000000
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OverflowTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.fail;
-
-import org.apache.logging.log4j.LoggingException;
-import org.junit.Test;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests StackOverflow when slf4j-impl and to-slf4j are both present.
- */
-public class OverflowTest {
-
- @Test
- public void log() {
- try {
- LoggerFactory.getLogger(OverflowTest.class);
- fail("Failed to detect inclusion of log4j-to-slf4j");
- } catch (LoggingException ex) {
- // Expected exception.
- } catch (StackOverflowError error) {
- fail("Failed to detect inclusion of log4j-to-slf4j, caught StackOverflowError");
- }
- }
-}
diff --git a/log4j-slf4j-impl/src/test/resources/log4j-test1.xml b/log4j-slf4j-impl/src/test/resources/log4j-test1.xml
deleted file mode 100644
index b3ad6067a1..0000000000
--- a/log4j-slf4j-impl/src/test/resources/log4j-test1.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<configuration status="error" name="LoggerTest">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <ThresholdFilter level="trace"/>
-
- <Appenders>
- <List name="EventLogger">
- <PatternLayout pattern="%C{1.} %m%n"/>
- </List>
- <Console name="STDOUT">
- <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
- </Console>
- <File name="File" fileName="${filename}">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <List name="List">
- <PatternLayout pattern="%C{1.} %m MDC%X%n%ex{0}"/>
- </List>
- <List name="UnformattedList" />
- <SLF4J name="SLF4J"/>
- </Appenders>
-
- <Loggers>
- <Logger name="EventLogger" level="info" additivity="false">
- <AppenderRef ref="EventLogger"/>
- </Logger>>
-
- <Logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <AppenderRef ref="File"/>
- </Logger>
-
- <Root level="trace">
- <AppenderRef ref="List"/>
- <AppenderRef ref="UnformattedList"/>
- </Root>
- </Loggers>
-
-</configuration>
diff --git a/log4j-slf4j-impl/src/test/resources/log4j2-1482.xml b/log4j-slf4j-impl/src/test/resources/log4j2-1482.xml
deleted file mode 100644
index af7af4a622..0000000000
--- a/log4j-slf4j-impl/src/test/resources/log4j2-1482.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<Configuration status="warn" name="MyApp">
- <Properties>
- <Property name="audit-path">target/log4j2-1482</Property>
- <Property name="file-name">audit</Property>
- <Property name="file-header">param1,param2,param3${sys:line.separator}
- </Property>
- </Properties>
-
- <Appenders>
- <RollingFile name="auditfile" fileName="${audit-path}/${file-name}.tmp"
- filePattern="${audit-path}/${file-name}-%d{yyyy-MM-dd}-%i.csv">
- <CsvParameterLayout delimiter="," header="${file-header}">
- </CsvParameterLayout>
- <Policies>
- <SizeBasedTriggeringPolicy size="80 B" />
- </Policies>
- <DefaultRolloverStrategy max="2" />
- </RollingFile>
- </Appenders>
-
- <Loggers>
- <Root level="info">
- <AppenderRef ref="auditfile" />
- </Root>
- </Loggers>
-</Configuration>
diff --git a/log4j-slf4j2-impl/pom.xml b/log4j-slf4j2-impl/pom.xml
deleted file mode 100644
index 7019645401..0000000000
--- a/log4j-slf4j2-impl/pom.xml
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${revision}</version>
- <relativePath>../log4j-parent</relativePath>
- </parent>
-
- <artifactId>log4j-slf4j2-impl</artifactId>
-
- <name>SLF4J 2 Provider for Log4j API</name>
-
- <description>SLF4J 2 provider (binding) for the Apache Log4j API.
- It forwards SLF4J 2 calls to the Log4j API.
- This effectively allows using Log4j as an implementation of SLF4J 2.
- (Refer to the `log4j-to-slf4j` artifact for forwarding the Log4j API to SLF4J.)</description>
-
- <properties>
-
- <!--
- ~ OSGi and JPMS options
- -->
- <bnd.baseline.skip>false</bnd.baseline.skip>
- <bnd-extra-module-options>
- <!-- The module descriptor is in `META-INF/versions/9`
- BND can not find it -->
- org.slf4j;substitute="slf4j-api"
- </bnd-extra-module-options>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.framework</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-to-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-csv</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>loop-test</id>
- <goals>
- <goal>test</goal>
- </goals>
- <phase>test</phase>
- <configuration>
- <includes>
- <include>**/OverflowTest.java</include>
- </includes>
- <includeJUnit5Engines>junit-vintage</includeJUnit5Engines>
- </configuration>
- </execution>
- <execution>
- <id>default-test</id>
- <goals>
- <goal>test</goal>
- </goals>
- <phase>test</phase>
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- <excludes>
- <exclude>**/OverflowTest.java</exclude>
- </excludes>
- <classpathDependencyExcludes>
- <classpathDependencyExcludes>org.apache.logging.log4j:log4j-to-slf4j</classpathDependencyExcludes>
- </classpathDependencyExcludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-</project>
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jEventBuilder.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jEventBuilder.java
deleted file mode 100644
index 474fb057dc..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jEventBuilder.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Supplier;
-import org.apache.logging.log4j.BridgeAware;
-import org.apache.logging.log4j.CloseableThreadContext;
-import org.apache.logging.log4j.CloseableThreadContext.Instance;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogBuilder;
-import org.apache.logging.log4j.Logger;
-import org.slf4j.Marker;
-import org.slf4j.spi.CallerBoundaryAware;
-import org.slf4j.spi.LoggingEventBuilder;
-
-public class Log4jEventBuilder implements LoggingEventBuilder, CallerBoundaryAware {
-
- private static final String FQCN = Log4jEventBuilder.class.getName();
-
- private final Log4jMarkerFactory markerFactory;
- private final Logger logger;
- private final List<Object> arguments = new ArrayList<>();
- private String message = null;
- private org.apache.logging.log4j.Marker marker = null;
- private Throwable throwable = null;
- private Map<String, String> keyValuePairs = null;
- private final Level level;
- private String fqcn = FQCN;
-
- public Log4jEventBuilder(final Log4jMarkerFactory markerFactory, final Logger logger, final Level level) {
- this.markerFactory = markerFactory;
- this.logger = logger;
- this.level = level;
- }
-
- @Override
- public LoggingEventBuilder setCause(final Throwable cause) {
- this.throwable = cause;
- return this;
- }
-
- @Override
- public LoggingEventBuilder addMarker(final Marker marker) {
- this.marker = markerFactory.getLog4jMarker(marker);
- return this;
- }
-
- @Override
- public LoggingEventBuilder addArgument(final Object p) {
- arguments.add(p);
- return this;
- }
-
- @Override
- public LoggingEventBuilder addArgument(final Supplier<?> objectSupplier) {
- arguments.add(objectSupplier.get());
- return this;
- }
-
- @Override
- public LoggingEventBuilder addKeyValue(final String key, final Object value) {
- if (keyValuePairs == null) {
- keyValuePairs = new HashMap<>();
- }
- keyValuePairs.put(key, String.valueOf(value));
- return this;
- }
-
- @Override
- public LoggingEventBuilder addKeyValue(final String key, final Supplier<Object> valueSupplier) {
- if (keyValuePairs == null) {
- keyValuePairs = new HashMap<>();
- }
- keyValuePairs.put(key, String.valueOf(valueSupplier.get()));
- return this;
- }
-
- @Override
- public LoggingEventBuilder setMessage(final String message) {
- this.message = message;
- return this;
- }
-
- @Override
- public LoggingEventBuilder setMessage(final Supplier<String> messageSupplier) {
- this.message = messageSupplier.get();
- return this;
- }
-
- @Override
- public void log() {
- final LogBuilder logBuilder = logger.atLevel(level).withMarker(marker).withThrowable(throwable);
- if (logBuilder instanceof BridgeAware) {
- ((BridgeAware) logBuilder).setEntryPoint(fqcn);
- }
- if (keyValuePairs == null || keyValuePairs.isEmpty()) {
- logBuilder.log(message, arguments.toArray());
- } else {
- try (final Instance c = CloseableThreadContext.putAll(keyValuePairs)) {
- logBuilder.log(message, arguments.toArray());
- }
- }
- }
-
- @Override
- public void log(final String message) {
- setMessage(message);
- log();
- }
-
- @Override
- public void log(final String message, final Object arg) {
- setMessage(message);
- addArgument(arg);
- log();
- }
-
- @Override
- public void log(final String message, final Object arg0, final Object arg1) {
- setMessage(message);
- addArgument(arg0);
- addArgument(arg1);
- log();
- }
-
- @Override
- public void log(final String message, final Object... args) {
- setMessage(message);
- for (final Object arg : args) {
- addArgument(arg);
- }
- log();
- }
-
- @Override
- public void log(final Supplier<String> messageSupplier) {
- setMessage(messageSupplier);
- log();
- }
-
- @Override
- public void setCallerBoundary(String fqcn) {
- this.fqcn = fqcn;
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
deleted file mode 100644
index feb730615d..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.slf4j.Marker;
-import org.slf4j.spi.LocationAwareLogger;
-import org.slf4j.spi.LoggingEventBuilder;
-
-/**
- * SLF4J logger implementation that uses Log4j.
- */
-public class Log4jLogger implements LocationAwareLogger {
-
- public static final String FQCN = Log4jLogger.class.getName();
-
- private final ExtendedLogger logger;
- private final String name;
- private final Log4jMarkerFactory markerFactory;
-
- public Log4jLogger(final Log4jMarkerFactory markerFactory, final ExtendedLogger logger, final String name) {
- this.markerFactory = markerFactory;
- this.logger = logger;
- this.name = name;
- }
-
- @Override
- public void trace(final String format) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format);
- }
-
- @Override
- public void trace(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, o);
- }
-
- @Override
- public void trace(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, arg1, arg2);
- }
-
- @Override
- public void trace(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, args);
- }
-
- @Override
- public void trace(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.TRACE, null, format, t);
- }
-
- @Override
- public boolean isTraceEnabled() {
- return logger.isEnabled(Level.TRACE, null, null);
- }
-
- @Override
- public boolean isTraceEnabled(final Marker marker) {
- return logger.isEnabled(Level.TRACE, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void trace(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void trace(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.TRACE, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void debug(final String format) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format);
- }
-
- @Override
- public void debug(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, o);
- }
-
- @Override
- public void debug(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, arg1, arg2);
- }
-
- @Override
- public void debug(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, args);
- }
-
- @Override
- public void debug(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.DEBUG, null, format, t);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return logger.isEnabled(Level.DEBUG, null, null);
- }
-
- @Override
- public boolean isDebugEnabled(final Marker marker) {
- return logger.isEnabled(Level.DEBUG, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void debug(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void debug(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.DEBUG, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void info(final String format) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format);
- }
-
- @Override
- public void info(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, o);
- }
-
- @Override
- public void info(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, arg1, arg2);
- }
-
- @Override
- public void info(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, args);
- }
-
- @Override
- public void info(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.INFO, null, format, t);
- }
-
- @Override
- public boolean isInfoEnabled() {
- return logger.isEnabled(Level.INFO, null, null);
- }
-
- @Override
- public boolean isInfoEnabled(final Marker marker) {
- return logger.isEnabled(Level.INFO, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void info(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void info(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.INFO, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void warn(final String format) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format);
- }
-
- @Override
- public void warn(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, o);
- }
-
- @Override
- public void warn(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, arg1, arg2);
- }
-
- @Override
- public void warn(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, args);
- }
-
- @Override
- public void warn(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.WARN, null, format, t);
- }
-
- @Override
- public boolean isWarnEnabled() {
- return logger.isEnabled(Level.WARN, null, null);
- }
-
- @Override
- public boolean isWarnEnabled(final Marker marker) {
- return logger.isEnabled(Level.WARN, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void warn(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void warn(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.WARN, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void error(final String format) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format);
- }
-
- @Override
- public void error(final String format, final Object o) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, o);
- }
-
- @Override
- public void error(final String format, final Object arg1, final Object arg2) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, arg1, arg2);
- }
-
- @Override
- public void error(final String format, final Object... args) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, args);
- }
-
- @Override
- public void error(final String format, final Throwable t) {
- logger.logIfEnabled(FQCN, Level.ERROR, null, format, t);
- }
-
- @Override
- public boolean isErrorEnabled() {
- return logger.isEnabled(Level.ERROR, null, null);
- }
-
- @Override
- public boolean isErrorEnabled(final Marker marker) {
- return logger.isEnabled(Level.ERROR, markerFactory.getLog4jMarker(marker), null);
- }
-
- @Override
- public void error(final Marker marker, final String s) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Object o) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, o);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Object o, final Object o1) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, o, o1);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Object... objects) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, objects);
- }
-
- @Override
- public void error(final Marker marker, final String s, final Throwable throwable) {
- logger.logIfEnabled(FQCN, Level.ERROR, markerFactory.getLog4jMarker(marker), s, throwable);
- }
-
- @Override
- public void log(
- final Marker marker,
- final String fqcn,
- final int level,
- final String message,
- final Object[] params,
- final Throwable throwable) {
- final Level log4jLevel = getLevel(level);
- final org.apache.logging.log4j.Marker log4jMarker = markerFactory.getLog4jMarker(marker);
-
- if (!logger.isEnabled(log4jLevel, log4jMarker, message, params)) {
- return;
- }
- final Message msg;
- final Throwable actualThrowable;
- if (params == null) {
- msg = new SimpleMessage(message);
- actualThrowable = throwable;
- } else {
- msg = new ParameterizedMessage(message, params, throwable);
- actualThrowable = throwable != null ? throwable : msg.getThrowable();
- }
- logger.logMessage(fqcn, log4jLevel, log4jMarker, msg, actualThrowable);
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- private static Level getLevel(final int i) {
- switch (i) {
- case TRACE_INT:
- return Level.TRACE;
- case DEBUG_INT:
- return Level.DEBUG;
- case INFO_INT:
- return Level.INFO;
- case WARN_INT:
- return Level.WARN;
- case ERROR_INT:
- return Level.ERROR;
- }
- return Level.ERROR;
- }
-
- @Override
- public LoggingEventBuilder makeLoggingEventBuilder(final org.slf4j.event.Level level) {
- final Level log4jLevel = getLevel(level.toInt());
- return new Log4jEventBuilder(markerFactory, logger, log4jLevel);
- }
-
- @Override
- public boolean isEnabledForLevel(final org.slf4j.event.Level level) {
- return logger.isEnabled(getLevel(level.toInt()));
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
deleted file mode 100644
index e5940be3fe..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.function.Predicate;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.spi.AbstractLoggerAdapter;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.StackLocatorUtil;
-import org.slf4j.ILoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * Log4j implementation of SLF4J ILoggerFactory interface.
- */
-public class Log4jLoggerFactory extends AbstractLoggerAdapter<Logger> implements ILoggerFactory {
-
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
- private static final String SLF4J_PACKAGE = "org.slf4j";
- private static final Predicate<Class<?>> CALLER_PREDICATE = clazz ->
- !AbstractLoggerAdapter.class.equals(clazz) && !clazz.getName().startsWith(SLF4J_PACKAGE);
- private static final String TO_SLF4J_CONTEXT = "org.apache.logging.slf4j.SLF4JLoggerContext";
-
- private final Log4jMarkerFactory markerFactory;
-
- public Log4jLoggerFactory(final Log4jMarkerFactory markerFactory) {
- this.markerFactory = markerFactory;
- }
-
- @Override
- protected Logger newLogger(final String name, final LoggerContext context) {
- final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
- return new Log4jLogger(markerFactory, validateContext(context).getLogger(key), name);
- }
-
- @Override
- protected LoggerContext getContext() {
- final Class<?> anchor = LogManager.getFactory().isClassLoaderDependent()
- ? StackLocatorUtil.getCallerClass(Log4jLoggerFactory.class, CALLER_PREDICATE)
- : null;
- LOGGER.trace("Log4jLoggerFactory.getContext() found anchor {}", anchor);
- return anchor == null ? LogManager.getContext(false) : getContext(anchor);
- }
-
- Log4jMarkerFactory getMarkerFactory() {
- return markerFactory;
- }
-
- private LoggerContext validateContext(final LoggerContext context) {
- if (TO_SLF4J_CONTEXT.equals(context.getClass().getName())) {
- throw new LoggingException("log4j-slf4j2-impl cannot be present with log4j-to-slf4j");
- }
- return context;
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java
deleted file mode 100644
index bae69e961d..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.ThreadContext.ContextStack;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.slf4j.spi.MDCAdapter;
-
-/**
- *
- */
-public class Log4jMDCAdapter implements MDCAdapter {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final ThreadLocalMapOfStacks mapOfStacks = new ThreadLocalMapOfStacks();
-
- @Override
- public void put(final String key, final String val) {
- ThreadContext.put(key, val);
- }
-
- @Override
- public String get(final String key) {
- return ThreadContext.get(key);
- }
-
- @Override
- public void remove(final String key) {
- ThreadContext.remove(key);
- }
-
- @Override
- public void clear() {
- ThreadContext.clearMap();
- }
-
- @Override
- public Map<String, String> getCopyOfContextMap() {
- return ThreadContext.getContext();
- }
-
- @Override
- public void setContextMap(final Map<String, String> map) {
- ThreadContext.clearMap();
- ThreadContext.putAll(map);
- }
-
- @Override
- public void pushByKey(final String key, final String value) {
- if (key == null) {
- ThreadContext.push(value);
- } else {
- final String oldValue = mapOfStacks.peekByKey(key);
- if (!Objects.equals(ThreadContext.get(key), oldValue)) {
- LOGGER.warn("The key {} was used in both the string and stack-valued MDC.", key);
- }
- mapOfStacks.pushByKey(key, value);
- ThreadContext.put(key, value);
- }
- }
-
- @Override
- public String popByKey(final String key) {
- if (key == null) {
- return ThreadContext.getDepth() > 0 ? ThreadContext.pop() : null;
- }
- final String value = mapOfStacks.popByKey(key);
- if (!Objects.equals(ThreadContext.get(key), value)) {
- LOGGER.warn("The key {} was used in both the string and stack-valued MDC.", key);
- }
- ThreadContext.put(key, mapOfStacks.peekByKey(key));
- return value;
- }
-
- @Override
- public Deque<String> getCopyOfDequeByKey(final String key) {
- if (key == null) {
- final ContextStack stack = ThreadContext.getImmutableStack();
- final Deque<String> copy = new ArrayDeque<>(stack.size());
- stack.forEach(copy::push);
- return copy;
- }
- return mapOfStacks.getCopyOfDequeByKey(key);
- }
-
- @Override
- public void clearDequeByKey(final String key) {
- if (key == null) {
- ThreadContext.clearStack();
- } else {
- mapOfStacks.clearByKey(key);
- ThreadContext.put(key, null);
- }
- }
-
- private static class ThreadLocalMapOfStacks {
-
- private final ThreadLocal<Map<String, Deque<String>>> tlMapOfStacks = ThreadLocal.withInitial(HashMap::new);
-
- public void pushByKey(final String key, final String value) {
- tlMapOfStacks
- .get()
- .computeIfAbsent(key, ignored -> new ArrayDeque<>())
- .push(value);
- }
-
- public String popByKey(final String key) {
- final Deque<String> deque = tlMapOfStacks.get().get(key);
- return deque != null ? deque.poll() : null;
- }
-
- public Deque<String> getCopyOfDequeByKey(final String key) {
- final Deque<String> deque = tlMapOfStacks.get().get(key);
- return deque != null ? new ArrayDeque<>(deque) : null;
- }
-
- public void clearByKey(final String key) {
- final Deque<String> deque = tlMapOfStacks.get().get(key);
- if (deque != null) {
- deque.clear();
- }
- }
-
- public String peekByKey(final String key) {
- final Deque<String> deque = tlMapOfStacks.get().get(key);
- return deque != null ? deque.peek() : null;
- }
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java
deleted file mode 100644
index e2fbe62491..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import org.apache.logging.log4j.MarkerManager;
-import org.slf4j.IMarkerFactory;
-import org.slf4j.Marker;
-
-/**
- * Log4j/SLF4J {@link Marker} type bridge.
- */
-class Log4jMarker implements Marker {
-
- public static final long serialVersionUID = 1590472L;
-
- private final IMarkerFactory factory;
-
- private final org.apache.logging.log4j.Marker marker;
-
- /**
- * Constructs a Log4jMarker using an existing Log4j {@link org.apache.logging.log4j.Marker}.
- * @param marker The Log4j Marker upon which to base this Marker.
- */
- public Log4jMarker(final IMarkerFactory markerFactory, final org.apache.logging.log4j.Marker marker) {
- this.factory = markerFactory;
- this.marker = marker;
- }
-
- @Override
- public void add(final Marker marker) {
- if (marker == null) {
- throw new IllegalArgumentException();
- }
- final Marker m = factory.getMarker(marker.getName());
- this.marker.addParents(((Log4jMarker) m).getLog4jMarker());
- }
-
- @Override
- public boolean contains(final Marker marker) {
- if (marker == null) {
- throw new IllegalArgumentException();
- }
- return this.marker.isInstanceOf(marker.getName());
- }
-
- @Override
- public boolean contains(final String s) {
- return s != null ? this.marker.isInstanceOf(s) : false;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Log4jMarker)) {
- return false;
- }
- final Log4jMarker other = (Log4jMarker) obj;
- return Objects.equals(marker, other.marker);
- }
-
- public org.apache.logging.log4j.Marker getLog4jMarker() {
- return marker;
- }
-
- @Override
- public String getName() {
- return marker.getName();
- }
-
- @Override
- public boolean hasChildren() {
- return marker.hasParents();
- }
-
- @Override
- public int hashCode() {
- return 31 + Objects.hashCode(marker);
- }
-
- @Override
- public boolean hasReferences() {
- return marker.hasParents();
- }
-
- @Override
- public Iterator<Marker> iterator() {
- final org.apache.logging.log4j.Marker[] log4jParents = this.marker.getParents();
- if (log4jParents == null) {
- return Collections.emptyIterator();
- }
- final List<Marker> parents = new ArrayList<>(log4jParents.length);
- for (final org.apache.logging.log4j.Marker m : log4jParents) {
- parents.add(factory.getMarker(m.getName()));
- }
- return parents.iterator();
- }
-
- @Override
- public boolean remove(final Marker marker) {
- return marker != null ? this.marker.remove(MarkerManager.getMarker(marker.getName())) : false;
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java
deleted file mode 100644
index cedfc06571..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.slf4j.IMarkerFactory;
-import org.slf4j.Marker;
-
-/**
- * Log4j/SLF4J bridge to create SLF4J Markers based on name or based on existing SLF4J Markers.
- */
-public class Log4jMarkerFactory implements IMarkerFactory {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<>();
-
- /**
- * Returns a Log4j Marker that is compatible with SLF4J.
- * @param name The name of the Marker.
- * @return A Marker.
- */
- @Override
- public Marker getMarker(final String name) {
- if (name == null) {
- throw new IllegalArgumentException("Marker name must not be null");
- }
- final Marker marker = markerMap.get(name);
- if (marker != null) {
- return marker;
- }
- final org.apache.logging.log4j.Marker log4jMarker = MarkerManager.getMarker(name);
- return addMarkerIfAbsent(name, log4jMarker);
- }
-
- private Marker addMarkerIfAbsent(final String name, final org.apache.logging.log4j.Marker log4jMarker) {
- final Marker marker = new Log4jMarker(this, log4jMarker);
- final Marker existing = markerMap.putIfAbsent(name, marker);
- return existing == null ? marker : existing;
- }
-
- /**
- * Returns a Log4j Marker converted from an existing custom SLF4J Marker.
- * @param marker The SLF4J Marker to convert.
- * @return A converted Log4j/SLF4J Marker.
- * @since 2.1
- */
- public Marker getMarker(final Marker marker) {
- if (marker == null) {
- throw new IllegalArgumentException("Marker must not be null");
- }
- final Marker m = markerMap.get(marker.getName());
- if (m != null) {
- return m;
- }
- return addMarkerIfAbsent(marker.getName(), convertMarker(marker));
- }
-
- /**
- * Gets the Log4j2 marker associated to this SLF4J marker or creates a new one.
- *
- * @param marker a SLF4J marker
- * @return a Log4j2 marker
- */
- org.apache.logging.log4j.Marker getLog4jMarker(final Marker marker) {
- if (marker == null) {
- return null;
- } else if (marker instanceof Log4jMarker) {
- return ((Log4jMarker) marker).getLog4jMarker();
- } else {
- return ((Log4jMarker) getMarker(marker)).getLog4jMarker();
- }
- }
-
- static org.apache.logging.log4j.Marker convertMarker(final Marker original) {
- if (original == null) {
- throw new IllegalArgumentException("Marker must not be null");
- }
- return convertMarker(original, new ArrayList<Marker>());
- }
-
- private static org.apache.logging.log4j.Marker convertMarker(
- final Marker original, final Collection<Marker> visited) {
- final org.apache.logging.log4j.Marker marker = MarkerManager.getMarker(original.getName());
- if (original.hasReferences()) {
- final Iterator<Marker> it = original.iterator();
- while (it.hasNext()) {
- final Marker next = it.next();
- if (visited.contains(next)) {
- LOGGER.warn("Found a cycle in Marker [{}]. Cycle will be broken.", next.getName());
- } else {
- visited.add(next);
- marker.addParents(convertMarker(next, visited));
- }
- }
- }
- return marker;
- }
-
- /**
- * Returns true if the Marker exists.
- * @param name The Marker name.
- * @return {@code true} if the Marker exists, {@code false} otherwise.
- */
- @Override
- public boolean exists(final String name) {
- return markerMap.containsKey(name);
- }
-
- /**
- * Log4j does not support detached Markers. This method always returns false.
- * @param name The Marker name.
- * @return {@code false}
- */
- @Override
- public boolean detachMarker(final String name) {
- return false;
- }
-
- /**
- * Log4j does not support detached Markers for performance reasons. The returned Marker is attached.
- * @param name The Marker name.
- * @return The named Marker (unmodified).
- */
- @Override
- public Marker getDetachedMarker(final String name) {
- LOGGER.warn("Log4j does not support detached Markers. Returned Marker [{}] will be unchanged.", name);
- return getMarker(name);
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java
deleted file mode 100644
index 57a65e1dfb..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-/**
- * Exception thrown when the SLF4J adapter encounters a problem.
- *
- */
-public class SLF4JLoggingException extends RuntimeException {
-
- /**
- * Generated serial version ID.
- */
- private static final long serialVersionUID = -1618650972455089998L;
-
- public SLF4JLoggingException(final String msg) {
- super(msg);
- }
-
- public SLF4JLoggingException(final String msg, final Exception ex) {
- super(msg, ex);
- }
-
- public SLF4JLoggingException(final Exception ex) {
- super(ex);
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/SLF4JServiceProvider.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/SLF4JServiceProvider.java
deleted file mode 100644
index abfdcd1972..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/SLF4JServiceProvider.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import aQute.bnd.annotation.Resolution;
-import aQute.bnd.annotation.spi.ServiceProvider;
-import org.slf4j.ILoggerFactory;
-import org.slf4j.IMarkerFactory;
-import org.slf4j.spi.MDCAdapter;
-
-@ServiceProvider(value = org.slf4j.spi.SLF4JServiceProvider.class, resolution = Resolution.MANDATORY)
-public class SLF4JServiceProvider implements org.slf4j.spi.SLF4JServiceProvider {
-
- public static final String REQUESTED_API_VERSION = "2.0.99";
-
- private ILoggerFactory loggerFactory;
- private Log4jMarkerFactory markerFactory;
- private MDCAdapter mdcAdapter;
-
- @Override
- public ILoggerFactory getLoggerFactory() {
- return loggerFactory;
- }
-
- @Override
- public IMarkerFactory getMarkerFactory() {
- return markerFactory;
- }
-
- @Override
- public MDCAdapter getMDCAdapter() {
- return mdcAdapter;
- }
-
- @Override
- public String getRequestedApiVersion() {
- return REQUESTED_API_VERSION;
- }
-
- @Override
- public void initialize() {
- markerFactory = new Log4jMarkerFactory();
- loggerFactory = new Log4jLoggerFactory(markerFactory);
- mdcAdapter = new Log4jMDCAdapter();
- }
-}
diff --git a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/package-info.java b/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/package-info.java
deleted file mode 100644
index d847bc764b..0000000000
--- a/log4j-slf4j2-impl/src/main/java/org/apache/logging/slf4j/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * SLF4J support. Note that this does indeed share the same package namespace as the one found in log4j-to-slf4j;
- * this is intentional. The two JARs should <em>not</em> be used at the same time! Thus, in an OSGi environment
- * where split packages are not allowed, this error is prevented due to both JARs sharing an exported package name.
- */
-@Export
-@Header(name = Constants.BUNDLE_ACTIVATIONPOLICY, value = Constants.ACTIVATION_LAZY)
-@Version("3.0.0")
-package org.apache.logging.slf4j;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.bundle.Header;
-import org.osgi.annotation.versioning.Version;
-import org.osgi.framework.Constants;
diff --git a/log4j-slf4j2-impl/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider b/log4j-slf4j2-impl/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
deleted file mode 100644
index 1577f12daf..0000000000
--- a/log4j-slf4j2-impl/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.logging.slf4j.SLF4JServiceProvider
\ No newline at end of file
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/other/pkg/LoggerContextAnchorTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/other/pkg/LoggerContextAnchorTest.java
deleted file mode 100644
index 5732c205a4..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/other/pkg/LoggerContextAnchorTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.other.pkg;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.status.StatusData;
-import org.apache.logging.log4j.status.StatusListener;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.Test;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test LoggerContext lookups by verifying the anchor class representing calling code.
- */
-public class LoggerContextAnchorTest {
- private static final String PREFIX = "Log4jLoggerFactory.getContext() found anchor class ";
-
- @Test
- public void testLoggerFactoryLookupClass() {
- final String fqcn = getAnchorFqcn(() -> LoggerFactory.getLogger(LoggerContextAnchorTest.class));
- assertEquals(getClass().getName(), fqcn);
- }
-
- @Test
- public void testLoggerFactoryLookupString() {
- final String fqcn = getAnchorFqcn(() -> LoggerFactory.getLogger("custom.logger"));
- assertEquals(getClass().getName(), fqcn);
- }
-
- @Test
- public void testLoggerFactoryGetILoggerFactoryLookup() {
- final String fqcn =
- getAnchorFqcn(() -> LoggerFactory.getILoggerFactory().getLogger("custom.logger"));
- assertEquals(getClass().getName(), fqcn);
- }
-
- private static String getAnchorFqcn(final Runnable runnable) {
- final List<String> results = new CopyOnWriteArrayList<>();
- final StatusListener listener = new StatusListener() {
- @Override
- public void log(final StatusData data) {
- final String formattedMessage = data.getMessage().getFormattedMessage();
- if (formattedMessage.startsWith(PREFIX)) {
- results.add(formattedMessage.substring(PREFIX.length()));
- }
- }
-
- @Override
- public Level getStatusLevel() {
- return Level.TRACE;
- }
-
- @Override
- public void close() {
- // nop
- }
- };
- final StatusLogger statusLogger = StatusLogger.getLogger();
- statusLogger.registerListener(listener);
- try {
- runnable.run();
- if (results.isEmpty()) {
- throw new AssertionError("Failed to locate an anchor lookup status message");
- }
- if (results.size() > 1) {
- throw new AssertionError("Found multiple anchor lines: " + results);
- }
- return results.get(0);
- } finally {
- statusLogger.removeListener(listener);
- }
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
deleted file mode 100644
index ca22e19fe4..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.spi.CallerBoundaryAware;
-import org.slf4j.spi.LoggingEventBuilder;
-
-public class CallerInformationTest {
-
- // config from log4j-core test-jar
- private static final String CONFIG = "log4j2-calling-class.xml";
-
- @ClassRule
- public static final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
-
- @Test
- public void testClassLogger() throws Exception {
- final ListAppender app = ctx.getListAppender("Class").clear();
- final Logger logger = LoggerFactory.getLogger("ClassLogger");
- logger.info("Ignored message contents.");
- logger.warn("Verifying the caller class is still correct.");
- logger.error("Hopefully nobody breaks me!");
- logger.atInfo().log("Ignored message contents.");
- logger.atWarn().log("Verifying the caller class is still correct.");
- logger.atError().log("Hopefully nobody breaks me!");
- final List<String> messages = app.getMessages();
- assertEquals("Incorrect number of messages.", 6, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
- }
- }
-
- @Test
- public void testMethodLogger() throws Exception {
- final ListAppender app = ctx.getListAppender("Method").clear();
- final Logger logger = LoggerFactory.getLogger("MethodLogger");
- logger.info("More messages.");
- logger.warn("CATASTROPHE INCOMING!");
- logger.error("ZOMBIES!!!");
- logger.warn("brains~~~");
- logger.info("Itchy. Tasty.");
- logger.atInfo().log("More messages.");
- logger.atWarn().log("CATASTROPHE INCOMING!");
- logger.atError().log("ZOMBIES!!!");
- logger.atWarn().log("brains~~~");
- logger.atInfo().log("Itchy. Tasty.");
- final List<String> messages = app.getMessages();
- assertEquals("Incorrect number of messages.", 10, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller method name.", "testMethodLogger", message);
- }
- }
-
- @Test
- public void testFqcnLogger() throws Exception {
- final ListAppender app = ctx.getListAppender("Fqcn").clear();
- final Logger logger = LoggerFactory.getLogger("FqcnLogger");
- LoggingEventBuilder loggingEventBuilder = logger.atInfo();
- ((CallerBoundaryAware) loggingEventBuilder).setCallerBoundary("MyFqcn");
- loggingEventBuilder.log("A message");
- final List<String> messages = app.getMessages();
- assertEquals("Incorrect number of messages.", 1, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect fqcn.", "MyFqcn", message);
- }
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/CustomFlatMarker.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/CustomFlatMarker.java
deleted file mode 100644
index 3d82209728..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/CustomFlatMarker.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.Iterator;
-import org.slf4j.Marker;
-
-/**
- * Test Marker that may contain no reference/parent Markers.
- * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-793">LOG4J2-793</a>
- */
-public class CustomFlatMarker implements Marker {
- private static final long serialVersionUID = -4115520883240247266L;
-
- private final String name;
-
- public CustomFlatMarker(final String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void add(final Marker reference) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean remove(final Marker reference) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean hasChildren() {
- return hasReferences();
- }
-
- @Override
- public boolean hasReferences() {
- return false;
- }
-
- @Override
- public Iterator<Marker> iterator() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean contains(final Marker other) {
- return false;
- }
-
- @Override
- public boolean contains(final String name) {
- return false;
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4j1222Test.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4j1222Test.java
deleted file mode 100644
index 85d9d0dff4..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4j1222Test.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests logging during shutdown.
- */
-public class Log4j1222Test {
-
- @Test
- public void homepageRendersSuccessfully() {
- System.setProperty("log4j.configurationFile", "log4j2-console.xml");
- Runtime.getRuntime().addShutdownHook(new ShutdownHook());
- }
-
- private static class ShutdownHook extends Thread {
-
- private static class Holder {
- private static final Logger LOGGER = LoggerFactory.getLogger(Log4j1222Test.class);
- }
-
- @Override
- public void run() {
- super.run();
- trigger();
- }
-
- private void trigger() {
- Holder.LOGGER.info("Attempt to trigger");
- assertTrue("Logger is of type " + Holder.LOGGER.getClass().getName(), Holder.LOGGER instanceof Log4jLogger);
- }
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java
deleted file mode 100644
index d8abaf65a4..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.core.test.layout.Log4j2_1482_Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests https://issues.apache.org/jira/browse/LOG4J2-1482
- */
-public class Log4j2_1482_Slf4jTest extends Log4j2_1482_Test {
-
- @Override
- protected void log(final int runNumber) {
- if (runNumber == 2) {
- // System.out.println("Set a breakpoint here.");
- }
- final Logger logger = LoggerFactory.getLogger("auditcsvfile");
- final int val1 = 9, val2 = 11, val3 = 12;
- logger.info("Info Message!", val1, val2, val3);
- logger.info("Info Message!", val1, val2, val3);
- logger.info("Info Message!", val1, val2, val3);
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jEventBuilderTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jEventBuilderTest.java
deleted file mode 100644
index 8441bb1c92..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jEventBuilderTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
-import org.apache.logging.log4j.core.test.junit.Named;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@LoggerContextSource("log4j2-config.xml")
-public class Log4jEventBuilderTest {
-
- private final Logger logger;
- private final ListAppender appender;
-
- public Log4jEventBuilderTest(@Named("List") final Appender appender) {
- logger = LoggerFactory.getLogger("org.apache.test.Log4jEventBuilderTest");
- this.appender = (ListAppender) appender;
- }
-
- @BeforeEach
- public void setUp() {
- appender.clear();
- }
-
- @Test
- public void testKeyValuePairs() {
- logger.atDebug().addKeyValue("testKeyValuePairs", "ok").log();
- final List<LogEvent> events = appender.getEvents();
- assertThat(events).hasSize(1);
- assertThat(events.get(0).getContextData().toMap()).containsEntry("testKeyValuePairs", "ok");
- }
-
- @Test
- public void testArguments() {
- logger.atDebug().setMessage("{}-{}").addArgument("a").addArgument("b").log();
- logger.atDebug().log("{}-{}", "a", "b");
- logger.atDebug().addArgument("a").log("{}-{}", "b");
- logger.atDebug().log("{}-{}", new Object[] {"a", "b"});
- assertThat(appender.getEvents()).hasSize(4).allMatch(event -> "a-b"
- .equals(event.getMessage().getFormattedMessage()));
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jMDCAdapterTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jMDCAdapterTest.java
deleted file mode 100644
index 0559608f46..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jMDCAdapterTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-public class Log4jMDCAdapterTest {
-
- private static final Log4jMDCAdapter MDC_ADAPTER = new Log4jMDCAdapter();
- private static final String KEY = "Log4j2";
-
- private static Deque<String> createDeque(final int size) {
- final Deque<String> result = new ArrayDeque<>(size);
- IntStream.range(0, size).mapToObj(Integer::toString).forEach(result::addLast);
- return result;
- }
-
- private static Deque<String> popDeque(final String key) {
- final Deque<String> result = new ArrayDeque<>();
- String value;
- while ((value = MDC_ADAPTER.popByKey(key)) != null) {
- result.addLast(value);
- }
- return result;
- }
-
- static Stream<String> keys() {
- return Stream.of(KEY, "", null);
- }
-
- @ParameterizedTest
- @MethodSource("keys")
- public void testPushPopByKey(final String key) {
- MDC_ADAPTER.clearDequeByKey(key);
- final Deque<String> expectedValues = createDeque(100);
- expectedValues.descendingIterator().forEachRemaining(v -> MDC_ADAPTER.pushByKey(key, v));
- assertThat(MDC_ADAPTER.getCopyOfDequeByKey(key)).containsExactlyElementsOf(expectedValues);
- assertThat(popDeque(key)).containsExactlyElementsOf(expectedValues);
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jMarkerTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jMarkerTest.java
deleted file mode 100644
index 837b392a69..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4jMarkerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class Log4jMarkerTest {
-
- private static Log4jMarkerFactory markerFactory;
-
- @BeforeClass
- public static void startup() {
- markerFactory = ((Log4jLoggerFactory) org.slf4j.LoggerFactory.getILoggerFactory()).getMarkerFactory();
- }
-
- @Test
- public void testEquals() {
- final Marker markerA = MarkerManager.getMarker(Log4jMarkerTest.class.getName() + "-A");
- final Marker markerB = MarkerManager.getMarker(Log4jMarkerTest.class.getName() + "-B");
- final Log4jMarker marker1 = new Log4jMarker(markerFactory, markerA);
- final Log4jMarker marker2 = new Log4jMarker(markerFactory, markerA);
- final Log4jMarker marker3 = new Log4jMarker(markerFactory, markerB);
- Assert.assertEquals(marker1, marker2);
- Assert.assertNotEquals(marker1, null);
- Assert.assertNotEquals(null, marker1);
- Assert.assertNotEquals(marker1, marker3);
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/LoggerContextTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/LoggerContextTest.java
deleted file mode 100644
index d77e1d4d34..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/LoggerContextTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-import org.apache.logging.log4j.core.LifeCycle;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.junit.Test;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests cleanup of the LoggerContexts.
- */
-public class LoggerContextTest {
-
- @Test
- public void testCleanup() throws Exception {
- final Log4jLoggerFactory factory = (Log4jLoggerFactory) LoggerFactory.getILoggerFactory();
- factory.getLogger("test");
- Set<LoggerContext> set = factory.getLoggerContexts();
- final LoggerContext ctx1 = set.toArray(LoggerContext.EMPTY_ARRAY)[0];
- assertTrue("LoggerContext is not enabled for shutdown", ctx1 instanceof LifeCycle);
- ((LifeCycle) ctx1).stop();
- set = factory.getLoggerContexts();
- assertTrue("Expected no LoggerContexts", set.isEmpty());
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
deleted file mode 100644
index c5780437a2..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.List;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.apache.logging.log4j.util.Strings;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.spi.LocationAwareLogger;
-import org.slf4j.spi.LoggingEventBuilder;
-
-/**
- *
- */
-public class LoggerTest {
-
- private static final String CONFIG = "log4j-test1.xml";
-
- @ClassRule
- public static LoggerContextRule ctx = new LoggerContextRule(CONFIG);
-
- Logger logger = LoggerFactory.getLogger("LoggerTest");
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void debugNoParms() {
- logger.debug("Debug message {}");
- verify("o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
- logger.debug("Debug message {}", (Object[]) null);
- verify("o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
- ((LocationAwareLogger) logger)
- .log(null, Log4jLogger.class.getName(), LocationAwareLogger.DEBUG_INT, "Debug message {}", null, null);
- verify("o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- verify("o.a.l.s.LoggerTest Hello, World MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void mdc() {
-
- MDC.put("TestYear", "2010");
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Strings.LINE_SEPARATOR);
- MDC.clear();
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void mdcStack() {
- MDC.pushByKey("TestYear", "2010");
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Strings.LINE_SEPARATOR);
- MDC.pushByKey("TestYear", "2011");
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{TestYear=2011}" + Strings.LINE_SEPARATOR);
- MDC.popByKey("TestYear");
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Strings.LINE_SEPARATOR);
- MDC.clear();
- logger.debug("Debug message");
- verify("o.a.l.s.LoggerTest Debug message MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- /**
- * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-793">LOG4J2-793</a>
- */
- @Test
- public void supportsCustomSLF4JMarkers() {
- final Marker marker = new CustomFlatMarker("TEST");
- logger.debug(marker, "Test");
- verify("o.a.l.s.LoggerTest Test MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void testRootLogger() {
- final Logger l = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
- assertNotNull("No Root Logger", l);
- assertEquals(Logger.ROOT_LOGGER_NAME, l.getName());
- }
-
- @Test
- public void doubleSubst() {
- logger.debug("Hello, {}", "Log4j {}");
- verify("o.a.l.s.LoggerTest Hello, Log4j {} MDC{}" + Strings.LINE_SEPARATOR);
- }
-
- @Test
- public void testThrowable() {
- final Throwable expected = new RuntimeException();
- logger.debug("Hello {}", expected);
- verifyThrowable(expected);
- logger.debug("Hello {}", (Object) expected);
- verifyThrowable(null);
- logger.debug("Hello", expected);
- verifyThrowable(expected);
- logger.debug("Hello {}! {}", "World!", expected);
- verifyThrowable(null);
- logger.debug("Hello {}!", "World!", expected);
- verifyThrowable(expected);
- final LocationAwareLogger lal = (LocationAwareLogger) logger;
- lal.log(null, LoggerTest.class.getName(), LocationAwareLogger.DEBUG_INT, "Hello {}", null, expected);
- verifyThrowable(expected);
- lal.log(
- null,
- LoggerTest.class.getName(),
- LocationAwareLogger.DEBUG_INT,
- "Hello {}",
- new Object[] {expected},
- null);
- verifyThrowable(null);
- lal.log(
- null,
- LoggerTest.class.getName(),
- LocationAwareLogger.DEBUG_INT,
- "Hello {}",
- new Object[] {"World!", expected},
- null);
- verifyThrowable(expected);
- }
-
- @Test
- public void testLazyLoggingEventBuilder() {
- final ListAppender appender = ctx.getListAppender("UnformattedList");
- final Level oldLevel = ctx.getRootLogger().getLevel();
- try {
- Configurator.setRootLevel(Level.ERROR);
- final LoggingEventBuilder builder = logger.makeLoggingEventBuilder(org.slf4j.event.Level.DEBUG);
- Configurator.setRootLevel(Level.DEBUG);
- builder.log();
- assertThat(appender.getEvents()).hasSize(1).map(LogEvent::getLevel).containsExactly(Level.DEBUG);
- } finally {
- Configurator.setRootLevel(oldLevel);
- }
- }
-
- private ListAppender getAppenderByName(final String name) {
- final ListAppender listApp = ctx.getListAppender(name);
- assertNotNull("Missing Appender", listApp);
- return listApp;
- }
-
- private void verify(final String expected) {
- final ListAppender listApp = getAppenderByName("List");
- final List<String> events = listApp.getMessages();
- assertEquals("Incorrect number of messages. Expected 1 Actual " + events.size(), 1, events.size());
- final String actual = events.get(0);
- assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
- listApp.clear();
- }
-
- private void verifyThrowable(final Throwable expected) {
- final ListAppender listApp = getAppenderByName("UnformattedList");
- final List<LogEvent> events = listApp.getEvents();
- assertEquals("Incorrect number of messages", 1, events.size());
- final LogEvent actual = events.get(0);
- assertEquals("Incorrect throwable.", expected, actual.getThrown());
- listApp.clear();
- }
-
- @Before
- @After
- public void cleanup() {
- MDC.clear();
- ctx.getListAppender("List").clear();
- ctx.getListAppender("UnformattedList").clear();
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java
deleted file mode 100644
index 0db3e30393..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- */
-public class MarkerTest {
-
- private static final String CHILD_MAKER_NAME = MarkerTest.class.getSimpleName() + "-TEST";
- private static final String PARENT_MARKER_NAME = MarkerTest.class.getSimpleName() + "-PARENT";
- private static Log4jMarkerFactory markerFactory;
-
- @BeforeClass
- public static void startup() {
- markerFactory = ((Log4jLoggerFactory) org.slf4j.LoggerFactory.getILoggerFactory()).getMarkerFactory();
- }
-
- @Before
- @After
- public void clearMarkers() {
- MarkerManager.clear();
- }
-
- @Test
- public void testAddMarker() {
- final String childMakerName = CHILD_MAKER_NAME + "-AM";
- final String parentMarkerName = PARENT_MARKER_NAME + "-AM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMakerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMarkerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMarkerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMakerName);
-
- assertTrue("Incorrect Marker class", slf4jMarker instanceof Log4jMarker);
- assertTrue(
- String.format(
- "%s (log4jMarker=%s) is not an instance of %s (log4jParent=%s) in Log4j",
- childMakerName, parentMarkerName, log4jMarker, log4jParent),
- log4jMarker.isInstanceOf(log4jParent));
- assertTrue(
- String.format(
- "%s (slf4jMarker=%s) is not an instance of %s (log4jParent=%s) in SLF4J",
- childMakerName, parentMarkerName, slf4jMarker, slf4jParent),
- slf4jMarker.contains(slf4jParent));
- }
-
- @Test
- public void testAddNullMarker() {
- final String childMarkerName = CHILD_MAKER_NAME + "-ANM";
- final String parentMakerName = PARENT_MARKER_NAME + "-ANM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final org.slf4j.Marker nullMarker = null;
- try {
- log4jSlf4jParent.add(nullMarker);
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- try {
- log4jSlf4jMarker.add(nullMarker);
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- }
-
- @Test
- public void testAddSameMarker() {
- final String childMarkerName = CHILD_MAKER_NAME + "-ASM";
- final String parentMakerName = PARENT_MARKER_NAME + "-ASM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- assertTrue(
- String.format(
- "%s (log4jMarker=%s) is not an instance of %s (log4jParent=%s) in Log4j",
- childMarkerName, parentMakerName, log4jMarker, log4jParent),
- log4jMarker.isInstanceOf(log4jParent));
- assertTrue(
- String.format(
- "%s (slf4jMarker=%s) is not an instance of %s (log4jParent=%s) in SLF4J",
- childMarkerName, parentMakerName, slf4jMarker, slf4jParent),
- slf4jMarker.contains(slf4jParent));
- }
-
- @Test
- public void testEquals() {
- final String childMarkerName = CHILD_MAKER_NAME + "-ASM";
- final String parentMakerName = PARENT_MARKER_NAME + "-ASM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jMarker2 = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Marker log4jMarker2 = MarkerManager.getMarker(childMarkerName);
- assertEquals(log4jMarker, log4jMarker2);
- assertEquals(slf4jMarker, slf4jMarker2);
- assertNotEquals(log4jParent, log4jMarker);
- assertNotEquals(slf4jParent, slf4jMarker);
- }
-
- @Test
- public void testContainsNullMarker() {
- final String childMarkerName = CHILD_MAKER_NAME + "-CM";
- final String parentMakerName = PARENT_MARKER_NAME + "-CM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final org.slf4j.Marker nullMarker = null;
- try {
- Assert.assertFalse(log4jSlf4jParent.contains(nullMarker));
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- try {
- Assert.assertFalse(log4jSlf4jMarker.contains(nullMarker));
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (final IllegalArgumentException e) {
- // expected
- }
- }
-
- @Test
- public void testContainsNullString() {
- final String childMarkerName = CHILD_MAKER_NAME + "-CS";
- final String parentMakerName = PARENT_MARKER_NAME + "-CS";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final String nullStr = null;
- Assert.assertFalse(log4jSlf4jParent.contains(nullStr));
- Assert.assertFalse(log4jSlf4jMarker.contains(nullStr));
- }
-
- @Test
- public void testRemoveNullMarker() {
- final String childMakerName = CHILD_MAKER_NAME + "-CM";
- final String parentMakerName = PARENT_MARKER_NAME + "-CM";
- final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMakerName);
- final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
- slf4jMarker.add(slf4jParent);
- final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
- final Marker log4jMarker = MarkerManager.getMarker(childMakerName);
- final Log4jMarker log4jSlf4jParent = new Log4jMarker(markerFactory, log4jParent);
- final Log4jMarker log4jSlf4jMarker = new Log4jMarker(markerFactory, log4jMarker);
- final org.slf4j.Marker nullMarker = null;
- Assert.assertFalse(log4jSlf4jParent.remove(nullMarker));
- Assert.assertFalse(log4jSlf4jMarker.remove(nullMarker));
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/OverflowTest.java b/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/OverflowTest.java
deleted file mode 100644
index a0e5b0001a..0000000000
--- a/log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/OverflowTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.fail;
-
-import org.apache.logging.log4j.LoggingException;
-import org.junit.Test;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests StackOverflow when slf4j-impl and to-slf4j are both present.
- */
-public class OverflowTest {
-
- @Test
- public void log() {
- try {
- LoggerFactory.getLogger(OverflowTest.class);
- fail("Failed to detect inclusion of log4j-to-slf4j");
- } catch (LoggingException ex) {
- // Expected exception.
- } catch (StackOverflowError error) {
- fail("Failed to detect inclusion of log4j-to-slf4j, caught StackOverflowError");
- }
- }
-}
diff --git a/log4j-slf4j2-impl/src/test/resources/log4j-test1.xml b/log4j-slf4j2-impl/src/test/resources/log4j-test1.xml
deleted file mode 100644
index 30126e627a..0000000000
--- a/log4j-slf4j2-impl/src/test/resources/log4j-test1.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<configuration status="error" name="LoggerTest">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <ThresholdFilter level="trace"/>
-
- <Appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
- </Console>
- <File name="File" fileName="${filename}">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <List name="List">
- <PatternLayout pattern="%C{1.} %m MDC%X%n%ex{0}"/>
- </List>
- <List name="UnformattedList" />
- <SLF4J name="SLF4J"/>
- </Appenders>
-
- <Loggers>
- <Logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <AppenderRef ref="File"/>
- </Logger>
-
- <Root level="trace">
- <AppenderRef ref="List"/>
- <AppenderRef ref="UnformattedList"/>
- </Root>
- </Loggers>
-
-</configuration>
diff --git a/log4j-slf4j2-impl/src/test/resources/log4j2-1482.xml b/log4j-slf4j2-impl/src/test/resources/log4j2-1482.xml
deleted file mode 100644
index af7af4a622..0000000000
--- a/log4j-slf4j2-impl/src/test/resources/log4j2-1482.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<Configuration status="warn" name="MyApp">
- <Properties>
- <Property name="audit-path">target/log4j2-1482</Property>
- <Property name="file-name">audit</Property>
- <Property name="file-header">param1,param2,param3${sys:line.separator}
- </Property>
- </Properties>
-
- <Appenders>
- <RollingFile name="auditfile" fileName="${audit-path}/${file-name}.tmp"
- filePattern="${audit-path}/${file-name}-%d{yyyy-MM-dd}-%i.csv">
- <CsvParameterLayout delimiter="," header="${file-header}">
- </CsvParameterLayout>
- <Policies>
- <SizeBasedTriggeringPolicy size="80 B" />
- </Policies>
- <DefaultRolloverStrategy max="2" />
- </RollingFile>
- </Appenders>
-
- <Loggers>
- <Root level="info">
- <AppenderRef ref="auditfile" />
- </Root>
- </Loggers>
-</Configuration>
diff --git a/log4j-slf4j2-impl/src/test/resources/log4j2-config.xml b/log4j-slf4j2-impl/src/test/resources/log4j2-config.xml
deleted file mode 100644
index d247bd15cd..0000000000
--- a/log4j-slf4j2-impl/src/test/resources/log4j2-config.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<Configuration name="ConfigTest" status="OFF" monitorInterval="5">
- <Appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <List name="List2">
- <PatternLayout pattern="%m%n"/>
- </List>
- <List name="List">
- </List>
- </Appenders>
- <Loggers>
- <Logger name="org.apache.test" level="trace" additivity="false">
- <AppenderRef ref="List"/>
- </Logger>
- <Root level="error">
- <AppenderRef ref="STDOUT"/>
- </Root>
- </Loggers>
-</Configuration>
diff --git a/log4j-spring-cloud-config-client/pom.xml b/log4j-spring-cloud-config-client/pom.xml
index a3c95c69d6..262af7ab6a 100644
--- a/log4j-spring-cloud-config-client/pom.xml
+++ b/log4j-spring-cloud-config-client/pom.xml
@@ -34,6 +34,7 @@
<properties>
<!-- Dependency version -->
+ <commons-logging.version>1.3.4</commons-logging.version>
<spring-boot.version>3.3.3</spring-boot.version>
<spring-cloud.version>4.1.4</spring-cloud.version>
<spring-framework.version>6.1.12</spring-framework.version>
@@ -58,6 +59,13 @@
<dependencyManagement>
<dependencies>
+ <!-- Spring requires an implementation of `commons-logging` and we excluded `spring-jcl` above -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons-logging.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
diff --git a/log4j-to-jul/pom.xml b/log4j-to-jul/pom.xml
deleted file mode 100644
index 477e6cfc84..0000000000
--- a/log4j-to-jul/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${revision}</version>
- <relativePath>../log4j-parent</relativePath>
- </parent>
- <artifactId>log4j-to-jul</artifactId>
- <packaging>jar</packaging>
- <name>Apache Log4j to JUL Bridge</name>
- <description>The Apache Log4j binding between Log4j 2 API and java.util.logging (JUL).</description>
- <inceptionYear>2022</inceptionYear>
-
- <properties>
- <bnd-extra-package-options>
- <!-- Annotations only -->
- org.jspecify.*;resolution:=optional
- </bnd-extra-package-options>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.jspecify</groupId>
- <artifactId>jspecify</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.framework</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava-testlib</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/Activator.java b/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/Activator.java
deleted file mode 100644
index 11c7c1456d..0000000000
--- a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/Activator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import org.apache.logging.log4j.util.ProviderActivator;
-import org.osgi.annotation.bundle.Header;
-import org.osgi.framework.Constants;
-
-@Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}")
-@Header(name = Constants.BUNDLE_ACTIVATIONPOLICY, value = Constants.ACTIVATION_LAZY)
-public class Activator extends ProviderActivator {
-
- public Activator() {
- super(new JULProvider());
- }
-}
diff --git a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLogger.java b/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLogger.java
deleted file mode 100644
index 1108107157..0000000000
--- a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLogger.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.logging.Logger;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.spi.AbstractLogger;
-
-/**
- * Implementation of {@link org.apache.logging.log4j.Logger} that's backed by a {@link Logger}.
- *
- * This implementation currently ignores {@link Marker}.
- *
- * @author <a href="http://www.vorburger.ch">Michael Vorburger.ch</a> for Google
- */
-final class JULLogger extends AbstractLogger {
- private static final long serialVersionUID = 1L;
-
- private final Logger logger;
-
- // This implementation is inspired by org.apache.logging.slf4j.SLF4JLogger
-
- public JULLogger(final String name, final MessageFactory messageFactory, final Logger logger) {
- super(name, messageFactory);
- this.logger = requireNonNull(logger, "logger");
- }
-
- public JULLogger(final String name, final Logger logger) {
- super(name);
- this.logger = requireNonNull(logger, "logger");
- }
-
- public Logger getWrappedLogger() {
- return logger;
- }
-
- @Override
- public void logMessage(
- final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
- final java.util.logging.Level julLevel = convertLevel(level);
- if (!logger.isLoggable(julLevel)) {
- return;
- }
- final LazyLog4jLogRecord record =
- new LazyLog4jLogRecord(fqcn, julLevel, message.getFormattedMessage()); // NOT getFormat()
- // NOT record.setParameters(message.getParameters()); BECAUSE getFormattedMessage() NOT getFormat()
- record.setLoggerName(getName());
- record.setThrown(t == null ? message.getThrowable() : t);
- logger.log(record);
- }
-
- // Convert Level in Log4j scale to JUL scale.
- // See getLevel() for the mapping. Note that JUL's FINEST & CONFIG are never returned because Log4j has no such
- // levels, and
- // that Log4j's FATAL is simply mapped to JUL's SEVERE as is Log4j's ERROR because JUL does not distinguish between
- // ERROR and FATAL.
- private java.util.logging.Level convertLevel(final Level level) {
- switch (level.getStandardLevel()) {
- // Test in logical order of likely frequency of use
- // Must be kept in sync with #getLevel()
- case ALL:
- return java.util.logging.Level.ALL;
- case TRACE:
- return java.util.logging.Level.FINER;
- case DEBUG:
- return java.util.logging.Level.FINE;
- case INFO:
- return java.util.logging.Level.INFO;
- case WARN:
- return java.util.logging.Level.WARNING;
- case ERROR:
- return java.util.logging.Level.SEVERE;
- case FATAL:
- return java.util.logging.Level.SEVERE;
- case OFF:
- return java.util.logging.Level.OFF;
- default:
- // This is tempting: throw new IllegalStateException("Impossible Log4j Level encountered: " +
- // level.intLevel());
- // But it's not a great idea, security wise. If an attacker *SOMEHOW* managed to create a Log4j Level
- // instance
- // with an unexpected level (through JVM de-serialization, despite readResolve() { return
- // Level.valueOf(this.name); },
- // or whatever other means), then we would blow up in a very unexpected place and way. Let us therefore
- // instead just
- // return SEVERE for unexpected values, because that's more likely to be noticed than a FINER.
- // Greetings, Michael Vorburger.ch <http://www.vorburger.ch>, for Google, on 2021.12.24.
- return java.util.logging.Level.SEVERE;
- }
- }
-
- /**
- * Level in Log4j scale.
- * JUL Levels are mapped as follows:
- * <ul>
- * <li>OFF => OFF
- * <li>SEVERE => ERROR
- * <li>WARNING => WARN
- * <li>INFO => INFO
- * <li>CONFIG => INFO
- * <li>FINE => DEBUG
- * <li>FINER => TRACE (as in https://github.com/apache/logging-log4j2/blob/a58a06bf2365165ac5abdde931bb4ecd1adf0b3c/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java#L55-L75)
- * <li>FINEST => TRACE
- * <li>ALL => ALL
- * </ul>
- *
- * Numeric JUL Levels that don't match the known levels are matched to the closest one.
- * For example, anything between OFF (Integer.MAX_VALUE) and SEVERE (1000) is returned as a Log4j FATAL.
- */
- @Override
- public Level getLevel() {
- final int julLevel = getEffectiveJULLevel().intValue();
- // Test in logical order of likely frequency of use
- // Must be kept in sync with #convertLevel()
- if (julLevel == java.util.logging.Level.ALL.intValue()) {
- return Level.ALL;
- }
- if (julLevel <= java.util.logging.Level.FINER.intValue()) {
- return Level.TRACE;
- }
- if (julLevel <= java.util.logging.Level.FINE.intValue()) { // includes FINER
- return Level.DEBUG;
- }
- if (julLevel <= java.util.logging.Level.INFO.intValue()) { // includes CONFIG
- return Level.INFO;
- }
- if (julLevel <= java.util.logging.Level.WARNING.intValue()) {
- return Level.WARN;
- }
- if (julLevel <= java.util.logging.Level.SEVERE.intValue()) {
- return Level.ERROR;
- }
- return Level.OFF;
- }
-
- private java.util.logging.Level getEffectiveJULLevel() {
- Logger current = logger;
- while (current.getLevel() == null && current.getParent() != null) {
- current = current.getParent();
- }
- if (current.getLevel() != null) {
- return current.getLevel();
- }
- // This is a safety fallback that is typically never reached, because usually the root Logger.getLogger("") has
- // a Level.
- // Since JDK 8 the LogManager$RootLogger does not have a default level, just a default effective level of INFO.
- return java.util.logging.Level.INFO;
- }
-
- private boolean isEnabledFor(final Level level, final Marker marker) {
- // E.g. we're logging WARN and more, so getLevel() is 300, if we're asked if we're
- // enabled for level ERROR which is 200, isLessSpecificThan() tests for >= so return true.
- return getLevel().isLessSpecificThan(level);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final CharSequence data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8,
- final Object p9) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-}
diff --git a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLoggerContext.java b/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLoggerContext.java
deleted file mode 100644
index 7d2c2351c6..0000000000
--- a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLoggerContext.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import java.util.logging.Logger;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.spi.LoggerRegistry;
-
-/**
- * Implementation of Log4j {@link LoggerContext} SPI.
- * This is a factory to produce {@link JULLogger} instances.
- *
- * @author <a href="http://www.vorburger.ch">Michael Vorburger.ch</a> for Google
- */
-class JULLoggerContext implements LoggerContext {
- private final LoggerRegistry<ExtendedLogger> loggerRegistry = new LoggerRegistry<>();
-
- // This implementation is strongly inspired by org.apache.logging.slf4j.SLF4JLoggerContext
-
- @Override
- public Object getExternalContext() {
- return null;
- }
-
- @Override
- public ExtendedLogger getLogger(final String name) {
- if (!loggerRegistry.hasLogger(name)) {
- loggerRegistry.putIfAbsent(name, null, new JULLogger(name, Logger.getLogger(name)));
- }
- return loggerRegistry.getLogger(name);
- }
-
- @Override
- public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) {
- if (!loggerRegistry.hasLogger(name, messageFactory)) {
- loggerRegistry.putIfAbsent(
- name, messageFactory, new JULLogger(name, messageFactory, Logger.getLogger(name)));
- }
- return loggerRegistry.getLogger(name, messageFactory);
- }
-
- @Override
- public boolean hasLogger(final String name) {
- return loggerRegistry.hasLogger(name);
- }
-
- @Override
- public boolean hasLogger(final String name, final MessageFactory messageFactory) {
- return loggerRegistry.hasLogger(name, messageFactory);
- }
-
- @Override
- public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass) {
- return loggerRegistry.hasLogger(name, messageFactoryClass);
- }
-}
diff --git a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLoggerContextFactory.java b/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLoggerContextFactory.java
deleted file mode 100644
index f241e075ae..0000000000
--- a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULLoggerContextFactory.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import java.net.URI;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-/**
- * Implementation of Log4j {@link LoggerContextFactory} SPI.
- * This is a factory to produce the (one and only) {@link JULLoggerContext} instance.
- *
- * @author <a href="http://www.vorburger.ch">Michael Vorburger.ch</a> for Google
- */
-public class JULLoggerContextFactory implements LoggerContextFactory {
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
- private static final LoggerContext context = new JULLoggerContext();
-
- // This implementation is strongly inspired by org.apache.logging.slf4j.SLF4JLoggerContextFactory
-
- public JULLoggerContextFactory() {
- boolean misconfigured = false;
- try {
- LoaderUtil.loadClass("org.apache.logging.log4j.jul.LogManager");
- misconfigured = true;
- } catch (final ClassNotFoundException classNotFoundIsGood) {
- LOGGER.debug("org.apache.logging.log4j.jul.LogManager is not on classpath. Good!");
- }
- if (misconfigured) {
- throw new IllegalStateException("log4j-jul JAR is mutually exclusive with the log4j-to-jul JAR"
- + "(the first routes calls from Log4j to JUL, the second from Log4j to JUL)");
- }
- }
-
- @Override
- public LoggerContext getContext(
- final String fqcn, final ClassLoader loader, final Object externalContext, final boolean currentContext) {
- return context;
- }
-
- @Override
- public LoggerContext getContext(
- final String fqcn,
- final ClassLoader loader,
- final Object externalContext,
- final boolean currentContext,
- final URI configLocation,
- final String name) {
- return context;
- }
-
- @Override
- public void removeContext(final LoggerContext ignored) {}
-
- @Override
- public boolean isClassLoaderDependent() {
- // context is always used
- return false;
- }
-}
diff --git a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULProvider.java b/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULProvider.java
deleted file mode 100644
index 7497e484f8..0000000000
--- a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/JULProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import aQute.bnd.annotation.Resolution;
-import aQute.bnd.annotation.spi.ServiceProvider;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-import org.apache.logging.log4j.spi.NoOpThreadContextMap;
-import org.apache.logging.log4j.spi.Provider;
-import org.apache.logging.log4j.spi.ThreadContextMap;
-import org.jspecify.annotations.NullMarked;
-
-/**
- * Bind the Log4j API to JUL.
- *
- * @author <a href="http://www.vorburger.ch">Michael Vorburger.ch</a> for Google
- */
-@NullMarked
-@ServiceProvider(value = Provider.class, resolution = Resolution.OPTIONAL)
-public class JULProvider extends Provider {
- private static final LoggerContextFactory CONTEXT_FACTORY = new JULLoggerContextFactory();
-
- public JULProvider() {
- super(20, CURRENT_VERSION, JULLoggerContextFactory.class, NoOpThreadContextMap.class);
- }
-
- @Override
- public LoggerContextFactory getLoggerContextFactory() {
- return CONTEXT_FACTORY;
- }
-
- @Override
- public ThreadContextMap getThreadContextMapInstance() {
- // JUL does not provide an MDC implementation
- return NoOpThreadContextMap.INSTANCE;
- }
-}
diff --git a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/LazyLog4jLogRecord.java b/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/LazyLog4jLogRecord.java
deleted file mode 100644
index 014aa8c4fd..0000000000
--- a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/LazyLog4jLogRecord.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import org.apache.logging.log4j.util.StackLocatorUtil;
-
-/**
- * Extension of {@link java.util.logging.LogRecord} with lazy get source related methods based on Log4j's {@link StackLocatorUtil#calcLocation(String)}.
- */
-final class LazyLog4jLogRecord extends LogRecord {
-
- private static final long serialVersionUID = 6798134264543826471L;
-
- // parent class LogRecord already has a needToInferCaller but it's private
- private transient boolean inferCaller = true;
-
- private final String fqcn;
-
- LazyLog4jLogRecord(final String fqcn, final Level level, final String msg) {
- super(level, msg);
- this.fqcn = fqcn;
- }
-
- @Override
- public String getSourceClassName() {
- if (inferCaller) {
- inferCaller();
- }
- return super.getSourceClassName();
- }
-
- @Override
- public String getSourceMethodName() {
- if (inferCaller) {
- inferCaller();
- }
- return super.getSourceMethodName();
- }
-
- private void inferCaller() {
- StackTraceElement location = null;
- if (fqcn != null) {
- location = StackLocatorUtil.calcLocation(fqcn);
- }
- if (location != null) {
- setSourceClassName(location.getClassName());
- setSourceMethodName(location.getMethodName());
- } else {
- setSourceClassName(null);
- setSourceMethodName(null);
- }
- inferCaller = false;
- }
-}
diff --git a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/package-info.java b/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/package-info.java
deleted file mode 100644
index aa117c7995..0000000000
--- a/log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Java JDK java.util.logging (JUL) bridge.
- * This sends all Log4j logs to JUL (not the other way around, there is another module for the opposite direction).
- *
- * @author <a href="http://www.vorburger.ch">Michael Vorburger.ch</a> for Google
- */
-@Export
-@Version("2.24.0")
-package org.apache.logging.log4j.tojul;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-to-jul/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider b/log4j-to-jul/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider
deleted file mode 100644
index 2ac36b5b8b..0000000000
--- a/log4j-to-jul/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.logging.log4j.tojul.JULProvider
diff --git a/log4j-to-jul/src/test/java/org/apache/logging/log4j/tojul/JULLoggerTest.java b/log4j-to-jul/src/test/java/org/apache/logging/log4j/tojul/JULLoggerTest.java
deleted file mode 100644
index 9f70a01b28..0000000000
--- a/log4j-to-jul/src/test/java/org/apache/logging/log4j/tojul/JULLoggerTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.logging.log4j.Level;
-import org.junit.jupiter.api.Test;
-
-public class JULLoggerTest {
-
- @Test
- public void testNotNullEffectiveLevel() {
- // Emulates the root logger found in Tomcat, with a null level
- // See: https://bz.apache.org/bugzilla/show_bug.cgi?id=66184
- final java.util.logging.Logger julLogger = new java.util.logging.Logger("", null) {};
- final JULLogger logger = new JULLogger("", julLogger);
- assertEquals(Level.INFO, logger.getLevel());
- }
-}
diff --git a/log4j-to-jul/src/test/java/org/apache/logging/log4j/tojul/LoggerTest.java b/log4j-to-jul/src/test/java/org/apache/logging/log4j/tojul/LoggerTest.java
deleted file mode 100644
index c2d65199aa..0000000000
--- a/log4j-to-jul/src/test/java/org/apache/logging/log4j/tojul/LoggerTest.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.tojul;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.common.testing.TestLogHandler;
-import java.io.IOException;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import org.apache.logging.log4j.LogManager;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-public class LoggerTest {
-
- // Save levels so that we can reset them @After clearLogs()
- private static final java.util.logging.Logger globalLogger = java.util.logging.Logger.getGlobal();
- private static final java.util.logging.Logger rootLogger = java.util.logging.Logger.getLogger("");
- private static final Level globalLevel = globalLogger.getLevel();
- private static final Level rootLevel = rootLogger.getLevel();
-
- private org.apache.logging.log4j.Logger log4jLogger;
- private java.util.logging.Logger julLogger;
- private Level julLoggerDefaultLevel;
-
- // https://javadoc.io/doc/com.google.guava/guava-testlib/latest/com/google/common/testing/TestLogHandler.html
- private TestLogHandler handler;
-
- @BeforeEach
- public void setupLogCapture() {
- handler = new TestLogHandler();
- // Beware, the order here should not be changed!
- // Let the bridge do whatever it does BEFORE we create a JUL Logger (which SHOULD be the same)
- log4jLogger = LogManager.getLogger(getClass());
- assertThat(log4jLogger).isInstanceOf(JULLogger.class);
- julLogger = java.util.logging.Logger.getLogger(getClass().getName());
- assertThat(julLogger).isSameAs(((JULLogger) log4jLogger).getWrappedLogger());
- julLogger.addHandler(handler);
-
- julLoggerDefaultLevel = julLogger.getLevel();
-
- // Check that there is no configuration file which invalidates our assumption that the root logger is the parent
- // of our julLogger
- assertThat(julLogger.getParent()).isEqualTo(rootLogger);
- }
-
- @AfterEach
- public void clearLogs() {
- julLogger.removeHandler(handler);
- // Reset all Levels what any tests set anymore
- julLogger.setLevel(julLoggerDefaultLevel);
- rootLogger.setLevel(rootLevel);
- globalLogger.setLevel(globalLevel);
- }
-
- @Test
- public void infoAtInfo() {
- julLogger.setLevel(Level.INFO);
- log4jLogger.info("hello, world");
-
- final List<LogRecord> logs = handler.getStoredLogRecords();
- assertThat(logs).hasSize(1);
- final LogRecord log1 = logs.get(0);
- assertThat(log1.getLoggerName()).isEqualTo(getClass().getName());
- assertThat(log1.getLevel()).isEqualTo(java.util.logging.Level.INFO);
- assertThat(log1.getMessage()).isEqualTo("hello, world");
- assertThat(log1.getParameters()).isNull();
- assertThat(log1.getThrown()).isNull();
- assertThat(log1.getSourceClassName()).isEqualTo(getClass().getName());
- assertThat(log1.getSourceMethodName()).isEqualTo("infoAtInfo");
- }
-
- @Test
- public void infoAtInfoWithParameters() {
- julLogger.setLevel(Level.INFO);
- log4jLogger.info("hello, {}", "world");
-
- final List<LogRecord> logs = handler.getStoredLogRecords();
- assertThat(logs).hasSize(1);
- final LogRecord log1 = logs.get(0);
- assertThat(log1.getMessage()).isEqualTo("hello, world");
- assertThat(log1.getParameters()).isNull();
- assertThat(log1.getThrown()).isNull();
- }
-
- @Test
- public void errorAtSevereWithException() {
- julLogger.setLevel(Level.SEVERE);
- log4jLogger.error("hello, {}", "world", new IOException("Testing, testing"));
-
- final List<LogRecord> logs = handler.getStoredLogRecords();
- assertThat(logs).hasSize(1);
- final LogRecord log1 = logs.get(0);
- assertThat(log1.getMessage()).isEqualTo("hello, world");
- assertThat(log1.getParameters()).isNull();
- assertThat(log1.getThrown()).isInstanceOf(IOException.class);
- }
-
- @Test
- public void infoAtInfoWithLogBuilder() {
- julLogger.setLevel(Level.INFO);
- log4jLogger.atInfo().log("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
- }
-
- @Test
- public void infoAtInfoOnParent() {
- julLogger.getParent().setLevel(Level.INFO);
- log4jLogger.info("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
- }
-
- @Test
- public void infoWithoutAnyLevel() {
- // We're not setting any level.
- log4jLogger.info("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
- }
-
- @Test
- public void debugAtInfo() {
- julLogger.setLevel(Level.INFO);
- log4jLogger.debug("hello, world");
- assertThat(handler.getStoredLogRecords()).isEmpty();
- }
-
- @Test
- public void debugAtFiner() {
- julLogger.setLevel(Level.FINER);
- log4jLogger.debug("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
- }
-
- @Test
- public void traceAtFine() {
- julLogger.setLevel(Level.FINE);
- log4jLogger.trace("hello, world");
- assertThat(handler.getStoredLogRecords()).isEmpty();
- }
-
- @Test
- public void traceAtAllOnParent() {
- julLogger.getParent().setLevel(Level.ALL);
- log4jLogger.trace("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
- }
-
- @Test
- public void fatalAtOff() {
- julLogger.getParent().setLevel(Level.OFF);
- log4jLogger.fatal("hello, world");
- assertThat(handler.getStoredLogRecords()).isEmpty();
- }
-
- @Test
- public void fatalAtSevere() {
- julLogger.getParent().setLevel(Level.SEVERE);
- log4jLogger.atFatal().log("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
- }
-
- @Test
- public void warnAtFatal() {
- julLogger.getParent().setLevel(Level.SEVERE);
- log4jLogger.atWarn().log("hello, world");
- assertThat(handler.getStoredLogRecords()).isEmpty();
- }
-
- @Test
- public void customLevelJustUnderWarning() {
- julLogger.getParent().setLevel(new CustomLevel("Just under Warning", Level.WARNING.intValue() - 1));
-
- log4jLogger.info("hello, world");
- assertThat(handler.getStoredLogRecords()).isEmpty();
-
- log4jLogger.warn("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
-
- log4jLogger.error("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(2);
- }
-
- @Test
- public void customLevelJustAboveWarning() {
- julLogger.getParent().setLevel(new CustomLevel("Just above Warning", Level.WARNING.intValue() + 1));
-
- log4jLogger.info("hello, world");
- assertThat(handler.getStoredLogRecords()).isEmpty();
-
- log4jLogger.warn("hello, world");
- assertThat(handler.getStoredLogRecords()).isEmpty();
-
- log4jLogger.error("hello, world");
- assertThat(handler.getStoredLogRecords()).hasSize(1);
- }
-
- @SuppressWarnings("serial")
- private static class CustomLevel extends Level {
- CustomLevel(final String name, final int value) {
- super(name, value);
- }
- }
-
- /**
- * Test that the {@link LogRecord#getSourceClassName()}, which we already tested above in infoAtInfo()
- * also works as expected if the logging happened in a class that we have called (indirect), not in the test method itself.
- */
- @Test
- public void indirectSource() {
- java.util.logging.Logger.getLogger(Another.class.getName()).setLevel(Level.INFO);
- new Another(handler);
- final List<LogRecord> logs = handler.getStoredLogRecords();
- assertThat(logs).hasSize(1);
- final LogRecord log1 = logs.get(0);
- assertThat(log1.getSourceClassName()).isEqualTo(Another.class.getName());
- assertThat(log1.getSourceMethodName()).isEqualTo("<init>");
- }
-
- static class Another {
- org.apache.logging.log4j.Logger anotherLog4jLogger = LogManager.getLogger(getClass());
- java.util.logging.Logger anotherJULLogger =
- java.util.logging.Logger.getLogger(getClass().getName());
-
- Another(final TestLogHandler handler) {
- anotherJULLogger.addHandler(handler);
- anotherLog4jLogger.info("hello, another world");
- }
- }
-
- @Test
- public void placeholdersInFormat() {
- julLogger.setLevel(Level.INFO);
- log4jLogger.info("hello, {0} {}", "world");
-
- final List<LogRecord> logs = handler.getStoredLogRecords();
- assertThat(logs).hasSize(1);
- final LogRecord log1 = logs.get(0);
- final String formattedMessage = new java.util.logging.SimpleFormatter().formatMessage(log1);
- assertThat(formattedMessage).isEqualTo("hello, {0} world");
- }
-
- @Test
- public void placeholdersInFormattedMessage() {
- julLogger.setLevel(Level.INFO);
- log4jLogger.info("hello, {}", "{0} world");
-
- final List<LogRecord> logs = handler.getStoredLogRecords();
- assertThat(logs).hasSize(1);
- final LogRecord log1 = logs.get(0);
- final String formattedMessage = new java.util.logging.SimpleFormatter().formatMessage(log1);
- assertThat(formattedMessage).isEqualTo("hello, {0} world");
- }
-}
diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml
deleted file mode 100644
index 1450ad9aa5..0000000000
--- a/log4j-to-slf4j/pom.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${revision}</version>
- <relativePath>../log4j-parent</relativePath>
- </parent>
-
- <artifactId>log4j-to-slf4j</artifactId>
-
- <name>Log4j API to SLF4J Adapter</name>
-
- <description>Forwards the Log4j API calls to SLF4J.
- (Refer to the `log4j-slf4j[2]-impl` artifacts for forwarding SLF4J to the Log4j API.)</description>
-
- <properties>
-
- <!--
- ~ OSGi and JPMS options
- -->
- <slf4j.support.range>[1.7,3)</slf4j.support.range>
- <bnd-extra-package-options>
- <!-- Annotations only -->
- org.jspecify.*;resolution:=optional,
- <!-- This bridge also support SLF4J 2.x -->
- org.slf4j.*;version="${slf4j.support.range}"
- </bnd-extra-package-options>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.framework</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jspecify</groupId>
- <artifactId>jspecify</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <!--
- ~ Unban Logback.
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>ban-logging-dependencies</id>
- <configuration>
- <rules>
- <bannedDependencies>
- <includes>
- <include>ch.qos.logback:*:*:*:test</include>
- </includes>
- </bannedDependencies>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java
deleted file mode 100644
index 5080869f5d..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.util.ProviderActivator;
-import org.osgi.annotation.bundle.Header;
-
-@Header(name = org.osgi.framework.Constants.BUNDLE_ACTIVATOR, value = "${@class}")
-@Header(
- name = org.osgi.framework.Constants.BUNDLE_ACTIVATIONPOLICY,
- value = org.osgi.framework.Constants.ACTIVATION_LAZY)
-public class Activator extends ProviderActivator {
-
- public Activator() {
- super(new SLF4JProvider());
- }
-}
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java
deleted file mode 100644
index 4f2ef190bb..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.logging.log4j.spi.CleanableThreadContextMap;
-import org.apache.logging.log4j.util.SortedArrayStringMap;
-import org.apache.logging.log4j.util.StringMap;
-import org.slf4j.MDC;
-
-/**
- * Bind the ThreadContextMap to the SLF4J MDC.
- */
-public class MDCContextMap implements CleanableThreadContextMap {
-
- private static final StringMap EMPTY_CONTEXT_DATA = new SortedArrayStringMap(1);
-
- static {
- EMPTY_CONTEXT_DATA.freeze();
- }
-
- @Override
- public void put(final String key, final String value) {
- MDC.put(key, value);
- }
-
- @Override
- public void putAll(final Map<String, String> m) {
- for (final Entry<String, String> entry : m.entrySet()) {
- MDC.put(entry.getKey(), entry.getValue());
- }
- }
-
- @Override
- public String get(final String key) {
- return MDC.get(key);
- }
-
- @Override
- public void remove(final String key) {
- MDC.remove(key);
- }
-
- @Override
- public void removeAll(final Iterable<String> keys) {
- for (final String key : keys) {
- MDC.remove(key);
- }
- }
-
- @Override
- public void clear() {
- MDC.clear();
- }
-
- @Override
- public boolean containsKey(final String key) {
- final Map<String, String> map = MDC.getCopyOfContextMap();
- return map != null && map.containsKey(key);
- }
-
- @Override
- public Map<String, String> getCopy() {
- final Map<String, String> contextMap = MDC.getCopyOfContextMap();
- return contextMap != null ? contextMap : new HashMap<>();
- }
-
- @Override
- public Map<String, String> getImmutableMapOrNull() {
- return MDC.getCopyOfContextMap();
- }
-
- @Override
- public boolean isEmpty() {
- final Map<String, String> map = MDC.getCopyOfContextMap();
- return map == null || map.isEmpty();
- }
-
- @Override
- public StringMap getReadOnlyContextData() {
- final Map<String, String> copy = getCopy();
- if (copy.isEmpty()) {
- return EMPTY_CONTEXT_DATA;
- }
- final StringMap result = new SortedArrayStringMap();
- for (final Entry<String, String> entry : copy.entrySet()) {
- result.putValue(entry.getKey(), entry.getValue());
- }
- return result;
- }
-}
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java
deleted file mode 100644
index 0d6df98dbe..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogBuilder;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LambdaUtil;
-import org.apache.logging.log4j.util.StackLocatorUtil;
-import org.apache.logging.log4j.util.Supplier;
-
-public class SLF4JLogBuilder implements LogBuilder {
-
- private static Message EMPTY_MESSAGE = new SimpleMessage("");
- private static final String FQCN = SLF4JLogBuilder.class.getName();
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private ExtendedLogger logger;
- private Level level;
- private Marker marker;
- private Throwable throwable;
- private volatile boolean inUse;
- private final long threadId;
-
- public SLF4JLogBuilder(final SLF4JLogger logger, final Level level) {
- this.logger = logger;
- this.level = level;
- this.threadId = Thread.currentThread().getId();
- this.inUse = level != null;
- }
-
- public SLF4JLogBuilder() {
- this(null, null);
- }
-
- public LogBuilder reset(final SLF4JLogger logger, final Level level) {
- this.logger = logger;
- this.level = level;
- this.marker = null;
- this.throwable = null;
- this.inUse = true;
- return this;
- }
-
- public boolean isInUse() {
- return this.inUse;
- }
-
- private boolean isValid() {
- if (!inUse) {
- LOGGER.warn("Attempt to reuse LogBuilder was ignored. {}", StackLocatorUtil.getCallerClass(2));
- return false;
- }
- if (this.threadId != Thread.currentThread().getId()) {
- LOGGER.warn("LogBuilder can only be used on the owning thread. {}", StackLocatorUtil.getCallerClass(2));
- return false;
- }
- return true;
- }
-
- private void logMessage(Message message) {
- try {
- logger.logMessage(FQCN, level, marker, message, throwable);
- } finally {
- inUse = false;
- }
- }
-
- @Override
- public LogBuilder withMarker(final Marker marker) {
- this.marker = marker;
- return this;
- }
-
- @Override
- public LogBuilder withThrowable(final Throwable throwable) {
- this.throwable = throwable;
- return this;
- }
-
- @Override
- public LogBuilder withLocation() {
- LOGGER.info("Call to withLocation() ignored since SLF4J does not support setting location information.");
- return this;
- }
-
- @Override
- public LogBuilder withLocation(final StackTraceElement location) {
- return withLocation();
- }
-
- @Override
- public void log(CharSequence message) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message));
- }
- }
-
- @Override
- public void log(String message) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message));
- }
- }
-
- @Override
- public void log(String message, Object... params) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, params));
- }
- }
-
- @Override
- public void log(String message, Supplier<?>... params) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, LambdaUtil.getAll(params)));
- }
- }
-
- @Override
- public void log(Message message) {
- if (isValid()) {
- logMessage(message);
- }
- }
-
- @Override
- public void log(final Supplier<Message> messageSupplier) {
- if (isValid()) {
- logMessage(messageSupplier.get());
- }
- }
-
- @Override
- public Message logAndGet(final Supplier<Message> messageSupplier) {
- Message message = null;
- if (isValid()) {
- logMessage(message = messageSupplier.get());
- }
- return message;
- }
-
- @Override
- public void log(Object message) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message));
- }
- }
-
- @Override
- public void log(String message, Object p0) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0));
- }
- }
-
- @Override
- public void log(String message, Object p0, Object p1) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1));
- }
- }
-
- @Override
- public void log(String message, Object p0, Object p1, Object p2) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2));
- }
- }
-
- @Override
- public void log(String message, Object p0, Object p1, Object p2, Object p3) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2, p3));
- }
- }
-
- @Override
- public void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2, p3, p4));
- }
- }
-
- @Override
- public void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2, p3, p4, p5));
- }
- }
-
- @Override
- public void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2, p3, p4, p5, p6));
- }
- }
-
- @Override
- public void log(
- String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2, p3, p4, p5, p6, p7));
- }
- }
-
- @Override
- public void log(
- String message,
- Object p0,
- Object p1,
- Object p2,
- Object p3,
- Object p4,
- Object p5,
- Object p6,
- Object p7,
- Object p8) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8));
- }
- }
-
- @Override
- public void log(
- String message,
- Object p0,
- Object p1,
- Object p2,
- Object p3,
- Object p4,
- Object p5,
- Object p6,
- Object p7,
- Object p8,
- Object p9) {
- if (isValid()) {
- logMessage(logger.getMessageFactory().newMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));
- }
- }
-
- @Override
- public void log() {
- if (isValid()) {
- logMessage(EMPTY_MESSAGE);
- }
- }
-}
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
deleted file mode 100644
index 26e94c67b3..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogBuilder;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.message.LoggerNameAwareMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.util.Constants;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MarkerFactory;
-import org.slf4j.spi.LocationAwareLogger;
-
-public class SLF4JLogger extends AbstractLogger {
-
- private static final long serialVersionUID = 1L;
- /**
- * Logback supports turbo filters, that can override the logger's level.
- * Therefore we can never return a no-op builder.
- */
- private static final boolean LAZY_LEVEL_CHECK = "ch.qos.logback.classic.LoggerContext"
- .equals(LoggerFactory.getILoggerFactory().getClass().getName());
-
- private static final ThreadLocal<SLF4JLogBuilder> logBuilder = ThreadLocal.withInitial(SLF4JLogBuilder::new);
-
- private final org.slf4j.Logger logger;
- private final LocationAwareLogger locationAwareLogger;
-
- public SLF4JLogger(final String name, final MessageFactory messageFactory, final org.slf4j.Logger logger) {
- super(name, messageFactory);
- this.logger = logger;
- this.locationAwareLogger = logger instanceof LocationAwareLogger ? (LocationAwareLogger) logger : null;
- }
-
- public SLF4JLogger(final String name, final org.slf4j.Logger logger) {
- super(name);
- this.logger = logger;
- this.locationAwareLogger = logger instanceof LocationAwareLogger ? (LocationAwareLogger) logger : null;
- }
-
- private int convertLevel(final Level level) {
- switch (level.getStandardLevel()) {
- case DEBUG:
- return LocationAwareLogger.DEBUG_INT;
- case TRACE:
- return LocationAwareLogger.TRACE_INT;
- case INFO:
- return LocationAwareLogger.INFO_INT;
- case WARN:
- return LocationAwareLogger.WARN_INT;
- case ERROR:
- return LocationAwareLogger.ERROR_INT;
- default:
- return LocationAwareLogger.ERROR_INT;
- }
- }
-
- @Override
- public Level getLevel() {
- if (logger.isTraceEnabled()) {
- return Level.TRACE;
- }
- if (logger.isDebugEnabled()) {
- return Level.DEBUG;
- }
- if (logger.isInfoEnabled()) {
- return Level.INFO;
- }
- if (logger.isWarnEnabled()) {
- return Level.WARN;
- }
- if (logger.isErrorEnabled()) {
- return Level.ERROR;
- }
- // Option: throw new IllegalStateException("Unknown SLF4JLevel");
- // Option: return Level.ALL;
- return Level.OFF;
- }
-
- public org.slf4j.Logger getLogger() {
- return locationAwareLogger != null ? locationAwareLogger : logger;
- }
-
- private static org.slf4j.Marker getMarker(final Marker marker) {
- // No marker is provided in the common case, small methods
- // are optimized more effectively.
- return marker == null ? null : convertMarker(marker);
- }
-
- private static org.slf4j.Marker convertMarker(final Marker marker) {
- final org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName());
- final Marker[] parents = marker.getParents();
- if (parents != null) {
- for (final Marker parent : parents) {
- final org.slf4j.Marker slf4jParent = getMarker(parent);
- if (!slf4jMarker.contains(slf4jParent)) {
- slf4jMarker.add(slf4jParent);
- }
- }
- }
- return slf4jMarker;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final CharSequence data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8,
- final Object p9) {
- return isEnabledFor(level, marker);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
- return isEnabledFor(level, marker);
- }
-
- private boolean isEnabledFor(final Level level, final Marker marker) {
- final org.slf4j.Marker slf4jMarker = getMarker(marker);
- switch (level.getStandardLevel()) {
- case DEBUG:
- return logger.isDebugEnabled(slf4jMarker);
- case TRACE:
- return logger.isTraceEnabled(slf4jMarker);
- case INFO:
- return logger.isInfoEnabled(slf4jMarker);
- case WARN:
- return logger.isWarnEnabled(slf4jMarker);
- case ERROR:
- return logger.isErrorEnabled(slf4jMarker);
- default:
- return logger.isErrorEnabled(slf4jMarker);
- }
- }
-
- @Override
- public void logMessage(
- final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
- final org.slf4j.Marker slf4jMarker = getMarker(marker);
- final String formattedMessage = message.getFormattedMessage();
- if (locationAwareLogger != null) {
- if (message instanceof LoggerNameAwareMessage) {
- ((LoggerNameAwareMessage) message).setLoggerName(getName());
- }
- locationAwareLogger.log(slf4jMarker, fqcn, convertLevel(level), formattedMessage, null, t);
- } else {
- switch (level.getStandardLevel()) {
- case DEBUG:
- logger.debug(slf4jMarker, formattedMessage, t);
- break;
- case TRACE:
- logger.trace(slf4jMarker, formattedMessage, t);
- break;
- case INFO:
- logger.info(slf4jMarker, formattedMessage, t);
- break;
- case WARN:
- logger.warn(slf4jMarker, formattedMessage, t);
- break;
- case ERROR:
- logger.error(slf4jMarker, formattedMessage, t);
- break;
- default:
- logger.error(slf4jMarker, formattedMessage, t);
- break;
- }
- }
- }
-
- @Override
- public LogBuilder always() {
- return atLevel(Level.OFF);
- }
-
- @Override
- public LogBuilder atTrace() {
- return atLevel(Level.TRACE);
- }
-
- @Override
- public LogBuilder atDebug() {
- return atLevel(Level.DEBUG);
- }
-
- @Override
- public LogBuilder atInfo() {
- return atLevel(Level.INFO);
- }
-
- @Override
- public LogBuilder atWarn() {
- return atLevel(Level.WARN);
- }
-
- @Override
- public LogBuilder atError() {
- return atLevel(Level.ERROR);
- }
-
- @Override
- public LogBuilder atFatal() {
- return atLevel(Level.TRACE);
- }
-
- @Override
- protected LogBuilder getLogBuilder(final Level level) {
- final SLF4JLogBuilder builder = logBuilder.get();
- return Constants.ENABLE_THREADLOCALS && !builder.isInUse()
- ? builder.reset(this, level)
- : new SLF4JLogBuilder(this, level);
- }
-
- @Override
- public LogBuilder atLevel(final Level level) {
- // TODO: wrap SLF4J 2.x LoggingEventBuilder
- if (LAZY_LEVEL_CHECK) {
- return getLogBuilder(level);
- }
- return super.atLevel(level);
- }
-}
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
deleted file mode 100644
index f0aee0af41..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.spi.LoggerRegistry;
-import org.slf4j.LoggerFactory;
-
-public class SLF4JLoggerContext implements LoggerContext {
- private final LoggerRegistry<ExtendedLogger> loggerRegistry = new LoggerRegistry<>();
-
- @Override
- public Object getExternalContext() {
- return null;
- }
-
- @Override
- public ExtendedLogger getLogger(final String name) {
- if (!loggerRegistry.hasLogger(name)) {
- loggerRegistry.putIfAbsent(name, null, new SLF4JLogger(name, LoggerFactory.getLogger(name)));
- }
- return loggerRegistry.getLogger(name);
- }
-
- @Override
- public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) {
- if (!loggerRegistry.hasLogger(name, messageFactory)) {
- loggerRegistry.putIfAbsent(
- name, messageFactory, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name)));
- }
- return loggerRegistry.getLogger(name, messageFactory);
- }
-
- @Override
- public boolean hasLogger(final String name) {
- return loggerRegistry.hasLogger(name);
- }
-
- @Override
- public boolean hasLogger(final String name, final MessageFactory messageFactory) {
- return loggerRegistry.hasLogger(name, messageFactory);
- }
-
- @Override
- public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass) {
- return loggerRegistry.hasLogger(name, messageFactoryClass);
- }
-}
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java
deleted file mode 100644
index e1ca5d4483..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.net.URI;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-public class SLF4JLoggerContextFactory implements LoggerContextFactory {
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
- private static final LoggerContext context = new SLF4JLoggerContext();
-
- public SLF4JLoggerContextFactory() {
- // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured)
- boolean misconfigured = false;
- try {
- LoaderUtil.loadClass("org.slf4j.helpers.Log4jLoggerFactory");
- misconfigured = true;
- } catch (final ClassNotFoundException classNotFoundIsGood) {
- LOGGER.debug("org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good!");
- }
- if (misconfigured) {
- throw new IllegalStateException("slf4j-impl jar is mutually exclusive with log4j-to-slf4j jar "
- + "(the first routes calls from SLF4J to Log4j, the second from Log4j to SLF4J)");
- }
- }
-
- @Override
- public LoggerContext getContext(
- final String fqcn, final ClassLoader loader, final Object externalContext, final boolean currentContext) {
- return context;
- }
-
- @Override
- public LoggerContext getContext(
- final String fqcn,
- final ClassLoader loader,
- final Object externalContext,
- final boolean currentContext,
- final URI configLocation,
- final String name) {
- return context;
- }
-
- @Override
- public void removeContext(final LoggerContext ignored) {}
-
- @Override
- public boolean isClassLoaderDependent() {
- // context is always used
- return false;
- }
-}
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java
deleted file mode 100644
index 52a11a5560..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import aQute.bnd.annotation.Resolution;
-import aQute.bnd.annotation.spi.ServiceProvider;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-import org.apache.logging.log4j.spi.Provider;
-import org.apache.logging.log4j.spi.ThreadContextMap;
-import org.jspecify.annotations.NullMarked;
-
-/**
- * Bind the Log4j API to SLF4J.
- */
-@NullMarked
-@ServiceProvider(value = Provider.class, resolution = Resolution.OPTIONAL)
-public class SLF4JProvider extends Provider {
-
- private static final LoggerContextFactory CONTEXT_FACTORY = new SLF4JLoggerContextFactory();
- private static final ThreadContextMap THREAD_CONTEXT_MAP = new MDCContextMap();
-
- public SLF4JProvider() {
- super(15, CURRENT_VERSION, SLF4JLoggerContextFactory.class, MDCContextMap.class);
- }
-
- @Override
- public LoggerContextFactory getLoggerContextFactory() {
- return CONTEXT_FACTORY;
- }
-
- @Override
- public ThreadContextMap getThreadContextMapInstance() {
- return THREAD_CONTEXT_MAP;
- }
-}
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java
deleted file mode 100644
index ba4cb130be..0000000000
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * SLF4J support.
- */
-@Export
-@Version("2.24.0")
-package org.apache.logging.slf4j;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider b/log4j-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider
deleted file mode 100644
index c66b5c946a..0000000000
--- a/log4j-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.logging.slf4j.SLF4JProvider
\ No newline at end of file
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
deleted file mode 100644
index b43a4ea68f..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.testUtil.StringListAppender;
-import java.util.List;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.test.junit.UsingStatusListener;
-import org.junit.jupiter.api.Test;
-
-@UsingStatusListener
-@LoggerContextSource
-public class CallerInformationTest {
-
- @Test
- public void testClassLogger() throws Exception {
- final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger");
- final StringListAppender<ILoggingEvent> app = TestUtil.getListAppender(logger, "Class");
- logger.info("Ignored message contents.");
- logger.warn("Verifying the caller class is still correct.");
- logger.error("Hopefully nobody breaks me!");
- final List<String> messages = app.strList;
- assertEquals("Incorrect number of messages.", 3, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
- }
- }
-
- @Test
- public void testMethodLogger() throws Exception {
- final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("MethodLogger");
- final StringListAppender<ILoggingEvent> app = TestUtil.getListAppender(logger, "Method");
- logger.info("More messages.");
- logger.warn("CATASTROPHE INCOMING!");
- logger.error("ZOMBIES!!!");
- logger.warn("brains~~~");
- logger.info("Itchy. Tasty.");
- final List<String> messages = app.strList;
- assertEquals("Incorrect number of messages.", 5, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller method name.", "testMethodLogger", message);
- }
- }
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java
deleted file mode 100644
index 18779b11ee..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Arrays;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests LOG4J2-1688 Multiple loggings of arguments are setting these arguments to null.
- */
-public class Log4j2Jira1688Test {
-
- @Test
- public void testLog4j2() {
-
- // Argument-array creation
- final int limit = 37;
- final Object[] args = createArray(limit);
- final Object[] originalArgs = Arrays.copyOf(args, args.length);
-
- System.out.println("args " + Arrays.toString(args));
-
- // Logger definition
- final String someFormat = "test {}";
- final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- // First logging of args
- logger.error(someFormat, args); // Only the first element (args[0]) of args will be logged - why?
- // GG: because the pattern {} picks up the 1 st argument, not the whole array
- assertThat(args).containsExactly(originalArgs);
-
- // Bug: The second logging of args sets all elements of args to null
- logger.error(someFormat, args);
- // GG: All is well args is still intact
- System.out.println("args " + Arrays.toString(args));
- assertThat(args).containsExactly(originalArgs);
- }
-
- /**
- * @param size
- * @return
- */
- private static Object[] createArray(final int size) {
- final Object[] args = new Object[size];
- for (int i = 0; i < args.length; i++) {
- args[i] = i;
- }
- return args;
- }
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java
deleted file mode 100644
index 8d073072b9..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.testUtil.StringListAppender;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.apache.logging.log4j.CloseableThreadContext;
-import org.apache.logging.log4j.CloseableThreadContext.Instance;
-import org.apache.logging.log4j.LogBuilder;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.test.junit.UsingStatusListener;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-@UsingStatusListener
-@LoggerContextSource
-public class LogBuilderTest {
-
- private static final CharSequence CHAR_SEQUENCE = "CharSequence";
- private static final String STRING = "String";
- private static final Message MESSAGE = new SimpleMessage();
- private static final Object[] P = {"p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8", "p9"};
- private static final Object OBJECT = "Object";
-
- // Log4j objects
- private static Logger logger;
- // Logback objects
- private static LoggerContext context;
- private static StringListAppender<ILoggingEvent> list;
-
- @BeforeAll
- public static void setUp() throws Exception {
- final org.slf4j.Logger slf4jLogger = context.getLogger(LogBuilderTest.class);
- logger = LogManager.getLogger(LogBuilderTest.class);
- assertThat(slf4jLogger).isSameAs(((SLF4JLogger) logger).getLogger());
- final ch.qos.logback.classic.Logger rootLogger = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
- rootLogger.detachAppender("console");
- list = TestUtil.getListAppender(rootLogger, "LIST");
- assertThat(list).isNotNull().extracting("strList").isNotNull();
- list.strList.clear();
- }
-
- static Stream<Consumer<LogBuilder>> logBuilderMethods() {
- return Stream.of(
- logBuilder -> logBuilder.log(),
- logBuilder -> logBuilder.log(CHAR_SEQUENCE),
- logBuilder -> logBuilder.log(MESSAGE),
- logBuilder -> logBuilder.log(OBJECT),
- logBuilder -> logBuilder.log(STRING),
- logBuilder -> logBuilder.log(STRING, P[0]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2], P[3]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2], P[3], P[4]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2], P[3], P[4], P[5]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2], P[3], P[4], P[5], P[6]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8]),
- logBuilder -> logBuilder.log(STRING, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9]),
- logBuilder -> logBuilder.log(STRING, P),
- logBuilder -> logBuilder.log(STRING, () -> OBJECT),
- logBuilder -> logBuilder.log(() -> MESSAGE));
- }
-
- @ParameterizedTest
- @MethodSource("logBuilderMethods")
- void testTurboFilter(final Consumer<LogBuilder> consumer) {
- consumer.accept(logger.atTrace());
- try (final Instance c = CloseableThreadContext.put("callerId", "Log4j2")) {
- consumer.accept(logger.atTrace());
- assertThat(list.strList).hasSize(1);
- }
- list.strList.clear();
- }
-
- @ParameterizedTest
- @MethodSource("logBuilderMethods")
- void testLevelThreshold(final Consumer<LogBuilder> consumer) {
- consumer.accept(logger.atInfo());
- assertThat(list.strList).hasSize(1);
- list.strList.clear();
- }
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java
deleted file mode 100644
index dc9dd5d343..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import ch.qos.logback.core.joran.spi.JoranException;
-import java.net.URL;
-import org.apache.logging.log4j.test.junit.ExtensionContextAnchor;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContext.Store;
-import org.junit.jupiter.api.extension.ExtensionContextException;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
-import org.junit.platform.commons.support.AnnotationSupport;
-import org.junit.platform.commons.support.HierarchyTraversalMode;
-import org.junit.platform.commons.support.ModifierSupport;
-import org.junit.platform.commons.support.ReflectionSupport;
-import org.slf4j.LoggerFactory;
-
-class LoggerContextResolver extends TypeBasedParameterResolver<LoggerContext>
- implements BeforeAllCallback, BeforeEachCallback {
-
- private static final Object KEY = LoggerContextHolder.class;
-
- @Override
- public void beforeEach(ExtensionContext extensionContext) throws Exception {
- final Class<?> testClass = extensionContext.getRequiredTestClass();
- if (AnnotationSupport.isAnnotated(testClass, LoggerContextSource.class)) {
- final LoggerContextHolder holder =
- ExtensionContextAnchor.getAttribute(KEY, LoggerContextHolder.class, extensionContext);
- if (holder == null) {
- throw new IllegalStateException(
- "Specified @LoggerContextSource but no LoggerContext found for test class "
- + testClass.getCanonicalName());
- }
- }
- AnnotationSupport.findAnnotation(extensionContext.getRequiredTestMethod(), LoggerContextSource.class)
- .ifPresent(source -> {
- final LoggerContextHolder holder = new LoggerContextHolder(source, extensionContext);
- ExtensionContextAnchor.setAttribute(KEY, holder, extensionContext);
- });
- final LoggerContextHolder holder =
- ExtensionContextAnchor.getAttribute(KEY, LoggerContextHolder.class, extensionContext);
- if (holder != null) {
- ReflectionSupport.findFields(
- extensionContext.getRequiredTestClass(),
- f -> ModifierSupport.isNotStatic(f) && f.getType().equals(LoggerContext.class),
- HierarchyTraversalMode.TOP_DOWN)
- .forEach(f -> {
- try {
- f.setAccessible(true);
- f.set(extensionContext.getRequiredTestInstance(), holder.getLoggerContext());
- } catch (ReflectiveOperationException e) {
- throw new ExtensionContextException("Failed to inject field " + f, e);
- }
- });
- }
- }
-
- @Override
- public void beforeAll(ExtensionContext extensionContext) throws Exception {
- final Class<?> testClass = extensionContext.getRequiredTestClass();
- AnnotationSupport.findAnnotation(testClass, LoggerContextSource.class).ifPresent(testSource -> {
- final LoggerContextHolder holder = new LoggerContextHolder(testSource, extensionContext);
- ExtensionContextAnchor.setAttribute(KEY, holder, extensionContext);
- });
- final LoggerContextHolder holder =
- ExtensionContextAnchor.getAttribute(KEY, LoggerContextHolder.class, extensionContext);
- if (holder != null) {
- ReflectionSupport.findFields(
- extensionContext.getRequiredTestClass(),
- f -> ModifierSupport.isStatic(f) && f.getType().equals(LoggerContext.class),
- HierarchyTraversalMode.TOP_DOWN)
- .forEach(f -> {
- try {
- f.setAccessible(true);
- f.set(null, holder.getLoggerContext());
- } catch (ReflectiveOperationException e) {
- throw new ExtensionContextException("Failed to inject field " + f, e);
- }
- });
- }
- }
-
- @Override
- public LoggerContext resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
- throws ParameterResolutionException {
- return ExtensionContextAnchor.getAttribute(KEY, LoggerContextHolder.class, extensionContext)
- .getLoggerContext();
- }
-
- static final class LoggerContextHolder implements Store.CloseableResource {
-
- private final LoggerContext context;
- private final Logger logger;
-
- private LoggerContextHolder(final LoggerContextSource source, final ExtensionContext extensionContext) {
- this.context = (LoggerContext) LoggerFactory.getILoggerFactory();
- Class<?> clazz = extensionContext.getRequiredTestClass();
- this.logger = context.getLogger(clazz);
-
- final JoranConfigurator configurator = new JoranConfigurator();
- final URL configLocation = getConfigLocation(source, extensionContext);
- configurator.setContext(context);
- try {
- configurator.doConfigure(configLocation);
- } catch (final JoranException e) {
- throw new ExtensionContextException("Failed to initialize Logback logger context for " + clazz, e);
- }
- }
-
- private static URL getConfigLocation(
- final LoggerContextSource source, final ExtensionContext extensionContext) {
- final String value = source.value();
- Class<?> clazz = extensionContext.getRequiredTestClass();
- URL url = null;
- if (value.isEmpty()) {
- while (clazz != null) {
- url = clazz.getResource(clazz.getSimpleName() + ".xml");
- if (url != null) {
- break;
- }
- clazz = clazz.getSuperclass();
- }
- } else {
- url = clazz.getClassLoader().getResource(value);
- }
- if (url != null) {
- return url;
- }
- throw new ExtensionContextException("Failed to find a default configuration for " + clazz);
- }
-
- public LoggerContext getLoggerContext() {
- return context;
- }
-
- public Logger getLogger() {
- return logger;
- }
-
- @Override
- public void close() {
- context.stop();
- }
- }
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java
deleted file mode 100644
index d71921c21f..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.logging.log4j.test.junit.TempLoggingDirectory;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- * Specifies a configuration file to use for unit tests.
- *
- * This is similar to the org.apache.logging.log4j.core.junit.LoggerContextSource annotation for Log4j.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Documented
-@Inherited
-@Tag("functional")
-@ExtendWith(TempLoggingDirectory.class)
-@ExtendWith(LoggerContextResolver.class)
-@ExtendWith(LoggerResolver.class)
-public @interface LoggerContextSource {
- /**
- * Specifies the name of the configuration file to use for the annotated test.
- * <p>
- * Defaults to the fully qualified name of the test class with '.xml' appended.
- * E.g. this class would have a default of
- * {@code org/apache/logging/log4j/core/test/junit/LoggerContextSource.xml}.
- * </p>
- */
- String value() default "";
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java
deleted file mode 100644
index 28f94113a3..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import ch.qos.logback.classic.Logger;
-import org.apache.logging.log4j.test.junit.ExtensionContextAnchor;
-import org.apache.logging.slf4j.LoggerContextResolver.LoggerContextHolder;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContextException;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
-import org.junit.platform.commons.support.HierarchyTraversalMode;
-import org.junit.platform.commons.support.ModifierSupport;
-import org.junit.platform.commons.support.ReflectionSupport;
-
-public class LoggerResolver extends TypeBasedParameterResolver<Logger>
- implements BeforeAllCallback, BeforeEachCallback {
-
- private static final Object KEY = LoggerContextHolder.class;
-
- @Override
- public Logger resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
- throws ParameterResolutionException {
- return ExtensionContextAnchor.getAttribute(KEY, LoggerContextHolder.class, extensionContext)
- .getLogger();
- }
-
- @Override
- public void beforeAll(ExtensionContext extensionContext) throws Exception {
- final LoggerContextHolder holder =
- ExtensionContextAnchor.getAttribute(KEY, LoggerContextHolder.class, extensionContext);
- if (holder != null) {
- ReflectionSupport.findFields(
- extensionContext.getRequiredTestClass(),
- f -> ModifierSupport.isStatic(f) && f.getType().equals(Logger.class),
- HierarchyTraversalMode.TOP_DOWN)
- .forEach(f -> {
- try {
- f.setAccessible(true);
- f.set(null, holder.getLogger());
- } catch (ReflectiveOperationException e) {
- throw new ExtensionContextException("Failed to inject field " + f, e);
- }
- });
- }
- }
-
- @Override
- public void beforeEach(ExtensionContext extensionContext) throws Exception {
- final LoggerContextHolder holder =
- ExtensionContextAnchor.getAttribute(KEY, LoggerContextHolder.class, extensionContext);
- if (holder != null) {
- ReflectionSupport.findFields(
- extensionContext.getRequiredTestClass(),
- f -> ModifierSupport.isNotStatic(f) && f.getType().equals(Logger.class),
- HierarchyTraversalMode.TOP_DOWN)
- .forEach(f -> {
- try {
- f.setAccessible(true);
- f.set(extensionContext.getRequiredTestInstance(), holder.getLogger());
- } catch (ReflectiveOperationException e) {
- throw new ExtensionContextException("Failed to inject field " + f, e);
- }
- });
- }
- }
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java
deleted file mode 100644
index 5f89d5a526..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.theInstance;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.testUtil.StringListAppender;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Proxy;
-import java.util.Date;
-import java.util.List;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.message.ParameterizedMessageFactory;
-import org.apache.logging.log4j.message.StringFormatterMessageFactory;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.MessageFactory2Adapter;
-import org.apache.logging.log4j.test.junit.UsingStatusListener;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.slf4j.MDC;
-
-@UsingStatusListener
-@LoggerContextSource
-public class LoggerTest {
-
- private static final Object OBJ = new Object();
- // Log4j objects
- private Logger logger;
- // Logback objects
- private LoggerContext context;
- private StringListAppender<ILoggingEvent> list;
-
- @BeforeEach
- public void setUp() throws Exception {
- final org.slf4j.Logger slf4jLogger = context.getLogger(getClass());
- logger = LogManager.getLogger();
- assertThat(slf4jLogger, is(theInstance(((SLF4JLogger) logger).getLogger())));
- final ch.qos.logback.classic.Logger rootLogger = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
- rootLogger.detachAppender("console");
- list = TestUtil.getListAppender(rootLogger, "LIST");
- assertThat(list, is(notNullValue()));
- assertThat(list.strList, is(notNullValue()));
- list.strList.clear();
- }
-
- @Test
- public void basicFlow() {
- logger.traceEntry();
- logger.traceExit();
- assertThat(list.strList, hasSize(2));
- }
-
- @Test
- public void basicFlowDepreacted() {
- logger.entry();
- logger.exit();
- assertThat(list.strList, hasSize(2));
- }
-
- @Test
- public void simpleFlowDeprecated() {
- logger.entry(OBJ);
- logger.exit(0);
- assertThat(list.strList, hasSize(2));
- }
-
- @Test
- public void simpleFlow() {
- logger.entry(OBJ);
- logger.traceExit(0);
- assertThat(list.strList, hasSize(2));
- }
-
- @Test
- public void throwing() {
- logger.throwing(new IllegalArgumentException("Test Exception"));
- assertThat(list.strList, hasSize(1));
- }
-
- @Test
- public void catching() {
- try {
- throw new NullPointerException();
- } catch (final Exception e) {
- logger.catching(e);
- }
- assertThat(list.strList, hasSize(1));
- }
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- assertThat(list.strList, hasSize(1));
- }
-
- @Test
- public void getLogger_String_MessageFactoryMismatch() {
- final Logger testLogger = testMessageFactoryMismatch(
- "getLogger_String_MessageFactoryMismatch",
- StringFormatterMessageFactory.INSTANCE,
- ParameterizedMessageFactory.INSTANCE);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertThat(list.strList, hasSize(1));
- assertThat(list.strList, hasItem(String.format("%,d", Integer.MAX_VALUE)));
- }
-
- @Test
- public void getLogger_String_MessageFactoryMismatchNull() {
- final Logger testLogger = testMessageFactoryMismatch(
- "getLogger_String_MessageFactoryMismatchNull", StringFormatterMessageFactory.INSTANCE, null);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertThat(list.strList, hasSize(1));
- assertThat(list.strList, hasItem(String.format("%,d", Integer.MAX_VALUE)));
- }
-
- private Logger testMessageFactoryMismatch(
- final String name, final MessageFactory messageFactory1, final MessageFactory messageFactory2) {
- final Logger testLogger = LogManager.getLogger(name, messageFactory1);
- assertThat(testLogger, is(notNullValue()));
- checkMessageFactory(messageFactory1, testLogger);
- final Logger testLogger2 = LogManager.getLogger(name, messageFactory2);
- checkMessageFactory(messageFactory2, testLogger2);
- return testLogger;
- }
-
- private static void checkMessageFactory(final MessageFactory messageFactory1, final Logger testLogger1) {
- if (messageFactory1 == null) {
- assertEquals(
- AbstractLogger.DEFAULT_MESSAGE_FACTORY_CLASS,
- testLogger1.getMessageFactory().getClass());
- } else {
- MessageFactory actual = testLogger1.getMessageFactory();
- if (actual instanceof MessageFactory2Adapter) {
- actual = ((MessageFactory2Adapter) actual).getOriginal();
- }
- assertEquals(messageFactory1, actual);
- }
- }
-
- @Test
- public void debugObject() {
- logger.debug(new Date());
- assertThat(list.strList, hasSize(1));
- }
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- assertThat(list.strList, hasSize(1));
- final String message = list.strList.get(0);
- assertEquals("Hello, World", message);
- }
-
- @Test
- public void paramIncludesSubstitutionMarker_locationAware() {
- logger.info("Hello, {}", "foo {} bar");
- assertThat(list.strList, hasSize(1));
- final String message = list.strList.get(0);
- assertEquals("Hello, foo {} bar", message);
- }
-
- @Test
- public void paramIncludesSubstitutionMarker_nonLocationAware() {
- final org.slf4j.Logger slf4jLogger = context.getLogger(getClass());
- final Logger nonLocationAwareLogger =
- new SLF4JLogger(slf4jLogger.getName(), (org.slf4j.Logger) Proxy.newProxyInstance(
- getClass().getClassLoader(), new Class<?>[] {org.slf4j.Logger.class}, (proxy, method, args) -> {
- try {
- return method.invoke(slf4jLogger, args);
- } catch (InvocationTargetException e) {
- throw e.getCause();
- }
- }));
- nonLocationAwareLogger.info("Hello, {}", "foo {} bar");
- assertThat(list.strList, hasSize(1));
- final String message = list.strList.get(0);
- assertEquals("Hello, foo {} bar", message);
- }
-
- @Test
- public void testImpliedThrowable() {
- logger.debug("This is a test", new Throwable("Testing"));
- final List<String> msgs = list.strList;
- assertThat(msgs, hasSize(1));
- final String expected = "java.lang.Throwable: Testing";
- assertTrue("Incorrect message data", msgs.get(0).contains(expected));
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void mdc() {
- ThreadContext.put("TestYear", Integer.toString(2010));
- logger.debug("Debug message");
- ThreadContext.clearMap();
- logger.debug("Debug message");
- assertThat(list.strList, hasSize(2));
- assertTrue("Incorrect year", list.strList.get(0).startsWith("2010"));
- }
-
- @Test
- public void mdcNullBackedIsEmpty() {
- assertNull("Setup wrong", MDC.getCopyOfContextMap());
- assertTrue(ThreadContext.isEmpty());
- }
-
- @Test
- public void mdcNullBackedContainsKey() {
- assertNull("Setup wrong", MDC.getCopyOfContextMap());
- assertFalse(ThreadContext.containsKey("something"));
- }
-
- @Test
- public void mdcNullBackedContainsNullKey() {
- assertNull("Setup wrong", MDC.getCopyOfContextMap());
- assertFalse(ThreadContext.containsKey(null));
- }
-
- @Test
- public void mdcContainsNullKey() {
- try {
- ThreadContext.put("some", "thing");
- assertNotNull("Setup wrong", MDC.getCopyOfContextMap());
- assertFalse(ThreadContext.containsKey(null));
- } finally {
- ThreadContext.clearMap();
- }
- }
-
- @Test
- public void mdcCannotContainNullKey() {
- try {
- ThreadContext.put(null, "something");
- fail("should throw");
- } catch (IllegalArgumentException | NullPointerException e) {
- // expected
- }
- }
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java
deleted file mode 100644
index 6673de4597..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-import org.apache.logging.log4j.spi.ThreadContextMap;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.Issue;
-import org.slf4j.MDCTestHelper;
-import org.slf4j.spi.MDCAdapter;
-
-class MDCContextMapTest {
-
- @Test
- @Issue("https://github.com/apache/logging-log4j2/issues/1426")
- void nonNullGetCopy() {
- final ThreadContextMap contextMap = new MDCContextMap();
- final MDCAdapter mockAdapter = mock(MDCAdapter.class);
- when(mockAdapter.getCopyOfContextMap()).thenReturn(null);
- final MDCAdapter adapter = MDCTestHelper.replaceMDCAdapter(mockAdapter);
- try {
- assertThat(contextMap.getImmutableMapOrNull()).isNull();
- assertThat(contextMap.getCopy()).isNotNull();
- verify(mockAdapter, times(2)).getCopyOfContextMap();
- verifyNoMoreInteractions(mockAdapter);
- } finally {
- MDCTestHelper.replaceMDCAdapter(adapter);
- }
- }
-}
diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java
deleted file mode 100644
index afcd9a81d4..0000000000
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.slf4j;
-
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.spi.AppenderAttachable;
-import ch.qos.logback.core.testUtil.StringListAppender;
-import org.slf4j.Logger;
-
-/**
- * Utility methods for unit tests integrating with Logback.
- *
- * @since 2.1
- */
-public final class TestUtil {
-
- public static StringListAppender<ILoggingEvent> getListAppender(final SLF4JLogger slf4jLogger, final String name) {
- final Logger logger = slf4jLogger.getLogger();
- if (!(logger instanceof AppenderAttachable)) {
- throw new AssertionError("SLF4JLogger.getLogger() did not return an instance of AppenderAttachable");
- }
- @SuppressWarnings("unchecked")
- final AppenderAttachable<ILoggingEvent> attachable = (AppenderAttachable<ILoggingEvent>) logger;
- return getListAppender(attachable, name);
- }
-
- public static StringListAppender<ILoggingEvent> getListAppender(
- final AppenderAttachable<ILoggingEvent> logger, final String name) {
- return (StringListAppender<ILoggingEvent>) logger.getAppender(name);
- }
-
- private TestUtil() {}
-}
diff --git a/log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java b/log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java
deleted file mode 100644
index 0256131b8f..0000000000
--- a/log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.slf4j;
-
-import org.slf4j.spi.MDCAdapter;
-
-public class MDCTestHelper {
-
- public static MDCAdapter replaceMDCAdapter(final MDCAdapter adapter) {
- final MDCAdapter old = MDC.mdcAdapter;
- MDC.mdcAdapter = adapter;
- return old;
- }
-}
diff --git a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml b/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml
deleted file mode 100644
index 9cef52d471..0000000000
--- a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<configuration>
- <!-- This test config is analogous to the log4j2-calling-class.xml test config -->
-
- <appender name="Class" class="ch.qos.logback.core.testUtil.StringListAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
- <pattern>%class</pattern>
- </layout>
- </appender>
- <logger name="ClassLogger" level="info" additivity="false">
- <appender-ref ref="Class"/>
- </logger>
-
- <appender name="Method" class="ch.qos.logback.core.testUtil.StringListAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
- <pattern>%method</pattern>
- </layout>
- </appender>
- <logger name="MethodLogger" level="info" additivity="false">
- <appender-ref ref="Method"/>
- </logger>
-</configuration>
diff --git a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml b/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml
deleted file mode 100644
index 9305cc8772..0000000000
--- a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<configuration>
-
- <turboFilter class="ch.qos.logback.classic.turbo.DynamicThresholdFilter">
- <OnHigherOrEqual>ACCEPT</OnHigherOrEqual>
- <Key>callerId</Key>
- <DefaultThreshold>INFO</DefaultThreshold>
- <MDCValueLevelPair>
- <value>Log4j2</value>
- <level>TRACE</level>
- </MDCValueLevelPair>
- </turboFilter>
-
- <appender name="LIST" class="ch.qos.logback.core.testUtil.StringListAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%msg</Pattern>
- </layout>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="LIST" />
- </root>
-</configuration>
diff --git a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml b/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml
deleted file mode 100644
index ec38ed6fc0..0000000000
--- a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<configuration>
-
- <appender name="LIST" class="ch.qos.logback.core.testUtil.StringListAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%X{TestYear}%msg</Pattern>
- </layout>
- </appender>
-
- <root level="trace">
- <appender-ref ref="LIST" />
- </root>
-</configuration>
diff --git a/pom.xml b/pom.xml
index a4b354f9b2..14fa733f63 100644
--- a/pom.xml
+++ b/pom.xml
@@ -259,11 +259,7 @@
<module>log4j-plugins</module>
<module>log4j-plugins-test</module>
<module>log4j-script</module>
- <module>log4j-slf4j2-impl</module>
- <module>log4j-slf4j-impl</module>
<module>log4j-spring-cloud-config-client</module>
- <module>log4j-to-jul</module>
- <module>log4j-to-slf4j</module>
</modules>
@@ -530,13 +526,13 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
- <version>${project.version}</version>
+ <version>${log4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
- <version>${project.version}</version>
+ <version>${log4j-api.version}</version>
</dependency>
<dependency>
@@ -548,13 +544,13 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-jul</artifactId>
- <version>${project.version}</version>
+ <version>${log4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
- <version>${project.version}</version>
+ <version>${log4j-api.version}</version>
</dependency>
<dependency>
diff --git a/src/site/antora/modules/ROOT/pages/components.adoc b/src/site/antora/modules/ROOT/pages/components.adoc
index 830ecc40b5..4017d513d4 100644
--- a/src/site/antora/modules/ROOT/pages/components.adoc
+++ b/src/site/antora/modules/ROOT/pages/components.adoc
@@ -296,7 +296,8 @@ See xref:manual/installation.adoc#impl-core-bridge-jul[Installing the JUL-to-Log
[IMPORTANT]
====
-Don't deploy this artifact together with <<log4j-to-jul>>.
+Don't deploy this artifact together with
+{log4j2-url}/components.html#log4j-to-jul[`log4j-to-jul`].
====
include::partial$components/log4j-jul.adoc[]
@@ -404,50 +405,6 @@ See xref:manual/scripts.adoc[] for more details.
include::partial$components/log4j-script.adoc[]
-[#log4j-slf4j2-impl]
-== `log4j-slf4j2-impl`
-
-[cols="1h,5"]
-|===
-| JPMS module
-| `org.apache.logging.log4j.slf4j2.impl`
-|===
-
-The `log4j-slf4j2-impl` artifact contains a bridge from
-https://www.slf4j.org/[SLF4J 2 API]
-to the xref:manual/api.adoc[].
-
-See xref:manual/installation.adoc#impl-core-bridge-slf4j[Installing the SLF4J-to-Log4j API bridge] for more details.
-
-[IMPORTANT]
-====
-Don't deploy this artifact together with either <<log4j-slf4j-impl>> or <<log4j-to-slf4j>>.
-====
-
-include::partial$components/log4j-slf4j2-impl.adoc[]
-
-[#log4j-slf4j-impl]
-== `log4j-slf4j-impl`
-
-[cols="1h,5"]
-|===
-| JPMS module
-| `org.apache.logging.log4j.slf4j.impl`
-|===
-
-The `log4j-slf4j-impl` artifact contains a bridge from
-https://www.slf4j.org/[SLF4J 1 API]
-to the xref:manual/api.adoc[].
-
-See xref:manual/installation.adoc#impl-core-bridge-slf4j[Installing the SLF4J-to-Log4j API bridge] for more details.
-
-[IMPORTANT]
-====
-Don't deploy this artifact together with either <<log4j-slf4j2-impl>> or <<log4j-to-slf4j>>.
-====
-
-include::partial$components/log4j-slf4j-impl.adoc[]
-
[#log4j-spring-cloud-config-client]
== `log4j-spring-cloud-config-client`
@@ -464,47 +421,3 @@ or earlier versions.
See xref:log4j-spring-cloud-config-client.adoc[] for more details.
include::partial$components/log4j-spring-cloud-config-client.adoc[]
-
-[#log4j-to-jul]
-== `log4j-to-jul`
-
-|===
-| JPMS module
-| `org.apache.logging.log4j.to.jul`
-|===
-
-The `log4j-jul` artifact contains an implementation of the
-xref:manual/api.adoc[]
-that logs to
-https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html[`java.util.logging`].
-
-See xref:manual/installation.adoc#impl-jul[Installing JUL] for more details.
-
-[IMPORTANT]
-====
-Don't deploy this artifact together with <<log4j-jul>>.
-====
-
-include::partial$components/log4j-to-jul.adoc[]
-
-[#log4j-to-slf4j]
-== `log4j-to-slf4j`
-
-|===
-| JPMS module
-| `org.apache.logging.log4j.to.slf4j`
-|===
-
-The `log4j-jul` artifact contains an implementation of the
-xref:manual/api.adoc[]
-that logs to
-https://www.slf4j.org/[SLF4J API].
-
-See xref:manual/installation.adoc#impl-logback[Installing Logback] for more details.
-
-[IMPORTANT]
-====
-Don't deploy this artifact together with either <<log4j-slf4j-impl>> or <<log4j-slf4j2-impl>>.
-====
-
-include::partial$components/log4j-to-slf4j.adoc[]
diff --git a/src/site/antora/modules/ROOT/pages/manual/installation.adoc b/src/site/antora/modules/ROOT/pages/manual/installation.adoc
index 719e097fb2..2fec226a38 100644
--- a/src/site/antora/modules/ROOT/pages/manual/installation.adoc
+++ b/src/site/antora/modules/ROOT/pages/manual/installation.adoc
@@ -231,14 +231,14 @@ The following sections explain the installation of Log4j-provided bridges.
You can translate {slf4j-url}[SLF4J] calls to Log4j API using the `log4j-slf4j2-impl` artifact:
-include::partial$components/log4j-slf4j2-impl.adoc[]
+include::partial$features/log4j-slf4j2-impl.adoc[]
.Are you still using SLF4J 1.x?
[%collapsible]
=====
Add this example instead:
-include::partial$components/log4j-slf4j-impl.adoc[]
+include::partial$features/log4j-slf4j-impl.adoc[]
=====
[#impl-core-bridge-jul]
@@ -465,6 +465,8 @@ Since it is embedded in the platform, it only requires the addition of bridges f
Maven::
+
+We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
++
[source,xml,subs="+attributes"]
----
<dependencies>
@@ -491,6 +493,8 @@ Maven::
Gradle::
+
+We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
++
[source,groovy,subs="+attributes"]
----
runtimeOnly 'org.apache.logging.log4j:log4j-to-jul' // Log4j-to-JUL bridge
@@ -511,6 +515,8 @@ To install {logback-url}[Logback] as the logging implementation, you only need t
Maven::
+
+We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
++
[source,xml]
----
<dependencies>
@@ -535,6 +541,8 @@ Maven::
Gradle::
+
+We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
++
[source,groovy,subs="+attributes"]
----
runtimeOnly 'ch.qos.logback:logback-classic:{logback-version}'
diff --git a/src/site/antora/modules/ROOT/partials/components/log4j-to-jul.adoc b/src/site/antora/modules/ROOT/partials/components/log4j-to-jul.adoc
deleted file mode 100644
index 7f0e1b6dfb..0000000000
--- a/src/site/antora/modules/ROOT/partials/components/log4j-to-jul.adoc
+++ /dev/null
@@ -1,41 +0,0 @@
-////
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-////
-
-[tabs]
-====
-Maven::
-+
-We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
-+
-[source,xml,subs="+attributes"]
-----
-<dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-to-jul</artifactId>
- <scope>runtime</scope>
-</dependency>
-----
-
-Gradle::
-+
-We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
-+
-[source,groovy,subs="+attributes"]
-----
-runtimeOnly 'org.apache.logging.log4j:log4j-to-jul'
-----
-====
\ No newline at end of file
diff --git a/src/site/antora/modules/ROOT/partials/components/log4j-to-slf4j.adoc b/src/site/antora/modules/ROOT/partials/components/log4j-to-slf4j.adoc
deleted file mode 100644
index 59221a0d3f..0000000000
--- a/src/site/antora/modules/ROOT/partials/components/log4j-to-slf4j.adoc
+++ /dev/null
@@ -1,41 +0,0 @@
-////
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-////
-
-[tabs]
-====
-Maven::
-+
-We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
-+
-[source,xml,subs="+attributes"]
-----
-<dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-to-slf4j</artifactId>
- <scope>runtime</scope>
-</dependency>
-----
-
-Gradle::
-+
-We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
-+
-[source,groovy,subs="+attributes"]
-----
-runtimeOnly 'org.apache.logging.log4j:log4j-to-slf4j'
-----
-====
\ No newline at end of file
diff --git a/src/site/antora/modules/ROOT/partials/components/log4j-slf4j-impl.adoc b/src/site/antora/modules/ROOT/partials/features/log4j-slf4j-impl.adoc
similarity index 100%
rename from src/site/antora/modules/ROOT/partials/components/log4j-slf4j-impl.adoc
rename to src/site/antora/modules/ROOT/partials/features/log4j-slf4j-impl.adoc
diff --git a/src/site/antora/modules/ROOT/partials/components/log4j-slf4j2-impl.adoc b/src/site/antora/modules/ROOT/partials/features/log4j-slf4j2-impl.adoc
similarity index 100%
rename from src/site/antora/modules/ROOT/partials/components/log4j-slf4j2-impl.adoc
rename to src/site/antora/modules/ROOT/partials/features/log4j-slf4j2-impl.adoc