This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-logging.git
The following commit(s) were added to refs/heads/master by this push: new c1e4fef Update from Logj 1 to the Log4j 2 API compatibility layer (#231) c1e4fef is described below commit c1e4fefc569df0b027bb344783e100e8c65a231b Author: Gary Gregory <garydgreg...@users.noreply.github.com> AuthorDate: Sat Mar 16 18:30:40 2024 -0400 Update from Logj 1 to the Log4j 2 API compatibility layer (#231) * Update from Logj1 to the 2 API compatibility layer * Update from Logj1 to the 2 API compatibility layer --- pom.xml | 78 +++++++++++++++++----- .../commons/logging/log4j/StandardTests.java | 4 +- .../log4j12/ApiClasspathStandardTestCase.java | 2 + .../log4j12/AppClasspathStandardTestCase.java | 2 + .../log4j12/ChildClasspathStandardTestCase.java | 2 + .../log4j12/ParentClasspathStandardTestCase.java | 2 + 6 files changed, 72 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 07dad4b..3cb4c62 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ under the License. <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <name>Apache Commons Logging</name> - <version>1.3.1-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <description>Apache Commons Logging is a thin adapter allowing configurable bridging to other, well-known logging systems.</description> <url>https://commons.apache.org/proper/commons-logging/</url> @@ -237,6 +237,7 @@ under the License. <exclude>org.slf4j:*</exclude> </classpathDependencyExcludes> <excludes> + <exclude>org/apache/commons/logging/log4j/log4j12/**</exclude> <exclude>org/apache/commons/logging/log4j2/**</exclude> <exclude>org/apache/commons/logging/slf4j/**</exclude> <exclude>org/apache/commons/logging/serviceloader/**</exclude> @@ -248,13 +249,13 @@ under the License. <!-- <org.apache.commons.logging.diagnostics.dest>STDOUT</org.apache.commons.logging.diagnostics.dest> --> - <log4j12>${log4j:log4j:jar}</log4j12> - <logkit>${logkit:logkit:jar}</logkit> - <servlet-api>${javax.servlet:servlet-api:jar}</servlet-api> - <commons-logging>target/${project.build.finalName}.jar</commons-logging> - <commons-logging-api>target/${project.build.finalName}-api.jar</commons-logging-api> - <commons-logging-adapters>target/${project.build.finalName}-adapters.jar</commons-logging-adapters> - <testclasses>target/${project.build.finalName}-tests.jar</testclasses> + <log4j12>${org.apache.logging.log4j:log4j-1.2-api:jar}</log4j12> + <logkit>${logkit:logkit:jar}</logkit> + <servlet-api>${javax.servlet:servlet-api:jar}</servlet-api> + <commons-logging>target/${project.build.finalName}.jar</commons-logging> + <commons-logging-api>target/${project.build.finalName}-api.jar</commons-logging-api> + <commons-logging-adapters>target/${project.build.finalName}-adapters.jar</commons-logging-adapters> + <testclasses>target/${project.build.finalName}-tests.jar</testclasses> </systemPropertyVariables> </configuration> </execution> @@ -277,7 +278,7 @@ under the License. </configuration> </execution> <!-- - - Tests logging through the Log4j API. + - Tests logging through the Log4j 2 API. --> <execution> <id>log4j-test</id> @@ -305,6 +306,53 @@ under the License. </systemPropertyVariables> </configuration> </execution> + <!-- + - Tests logging through the Log4j 2 API for 1.2. + --> + <execution> + <id>log4j12-test</id> + <goals> + <goal>integration-test</goal> + </goals> + <configuration> + <additionalClasspathDependencies> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-1.2-api</artifactId> + <version>${log4j2.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>${log4j2.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4j2.version}</version> + </dependency> + </additionalClasspathDependencies> + <includes> + <include>org/apache/commons/logging/log4j/log4j12/*TestCase.java</include> + </includes> + <systemPropertyVariables> + <!-- Due to a bug in `log4j-core-test`, + ~ the default LogEventFactory loses the location info. + ~ We need to force the usage of the reusable version. + <log4j2.messageFactory>org.apache.logging.log4j.message.ParameterizedMessageFactory</log4j2.messageFactory> + --> + <log4j2.logEventFactory>org.apache.logging.log4j.core.impl.ReusableLogEventFactory</log4j2.logEventFactory> + <log4j12>${org.apache.logging.log4j:log4j-1.2-api:jar}</log4j12> + <log4j2-api>${org.apache.logging.log4j:log4j-api:jar}</log4j2-api> + <log4j2-core>${org.apache.logging.log4j:log4j-core:jar}</log4j2-core> + <commons-logging>target/${project.build.finalName}.jar</commons-logging> + <commons-logging-api>target/${project.build.finalName}-api.jar</commons-logging-api> + <testclasses>target/${project.build.finalName}-tests.jar</testclasses> + <!-- Use the Log4j 1.2 version of Log --> + <org.apache.commons.logging.LogFactory>org.apache.commons.logging.impl.LogFactoryImpl</org.apache.commons.logging.LogFactory> + </systemPropertyVariables> + </configuration> + </execution> <!-- - Tests falling back to the SLF4J API, when the Log4j API is absent. --> @@ -477,9 +525,9 @@ under the License. <optional>true</optional> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.17</version> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-1.2-api</artifactId> + <version>${log4j2.version}</version> <optional>true</optional> </dependency> <dependency> @@ -603,9 +651,9 @@ under the License. <maven.compiler.target>${commons.logging.javaversion}</maven.compiler.target> <commons.componentid>logging</commons.componentid> <commons.module.name>org.apache.commons.logging</commons.module.name> - <commons.release.version>1.3.0</commons.release.version> - <commons.release.next>1.3.1</commons.release.next> - <commons.bc.version>1.2</commons.bc.version> + <commons.release.version>1.4.0</commons.release.version> + <commons.release.next>1.4.1</commons.release.next> + <commons.bc.version>1.3.0</commons.bc.version> <commons.release.isDistModule>true</commons.release.isDistModule> <commons.jira.id>LOGGING</commons.jira.id> <commons.jira.pid>12310484</commons.jira.pid> diff --git a/src/test/java/org/apache/commons/logging/log4j/StandardTests.java b/src/test/java/org/apache/commons/logging/log4j/StandardTests.java index 4bb2f5c..7bb6922 100644 --- a/src/test/java/org/apache/commons/logging/log4j/StandardTests.java +++ b/src/test/java/org/apache/commons/logging/log4j/StandardTests.java @@ -147,9 +147,7 @@ public abstract class StandardTests extends TestCase { public void testCreateFactory() { final LogFactory factory = LogFactory.getFactory(); assertNotNull("LogFactory exists", factory); - assertEquals("LogFactory class", - "org.apache.commons.logging.impl.LogFactoryImpl", - factory.getClass().getName()); + assertEquals("LogFactory class", "org.apache.commons.logging.impl.LogFactoryImpl", factory.getClass().getName()); final String[] names = factory.getAttributeNames(); assertNotNull("Names exists", names); diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java index ae914bb..9d555a5 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java @@ -45,6 +45,8 @@ public class ApiClasspathStandardTestCase extends TestCase { final PathableClassLoader child = new PathableClassLoader(parent); child.addLogicalLib("log4j12"); + child.addLogicalLib("log4j2-api"); + child.addLogicalLib("log4j2-core"); child.addLogicalLib("commons-logging"); child.addLogicalLib("testclasses"); diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java index 2f348ab..cd9d402 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java @@ -42,6 +42,8 @@ public class AppClasspathStandardTestCase extends TestCase { loader.useExplicitLoader("junit.", Test.class.getClassLoader()); loader.addLogicalLib("testclasses"); loader.addLogicalLib("log4j12"); + loader.addLogicalLib("log4j2-api"); + loader.addLogicalLib("log4j2-core"); loader.addLogicalLib("commons-logging"); final Class testClass = loader.loadClass( diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java index b78b7ea..600e1ce 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java @@ -44,6 +44,8 @@ public class ChildClasspathStandardTestCase extends TestCase { final PathableClassLoader child = new PathableClassLoader(parent); child.addLogicalLib("testclasses"); child.addLogicalLib("log4j12"); + child.addLogicalLib("log4j2-api"); + child.addLogicalLib("log4j2-core"); child.addLogicalLib("commons-logging"); final Class testClass = child.loadClass( diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java index 5c30cac..8343d10 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java @@ -42,6 +42,8 @@ public class ParentClasspathStandardTestCase extends TestCase { parent.useExplicitLoader("junit.", Test.class.getClassLoader()); parent.addLogicalLib("commons-logging"); parent.addLogicalLib("log4j12"); + parent.addLogicalLib("log4j2-api"); + parent.addLogicalLib("log4j2-core"); final PathableClassLoader child = new PathableClassLoader(parent); child.addLogicalLib("testclasses");