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
This commit is contained in:
78
pom.xml
78
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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user