diff --git a/apache-log4j-2.11.1-src.tar.gz b/apache-log4j-2.13.2-src.tar.gz similarity index 45% rename from apache-log4j-2.11.1-src.tar.gz rename to apache-log4j-2.13.2-src.tar.gz index 64d5d9f5d32297d9e433318667953a05a6329e80..e5d64b8defd2e30b908c9b20a83c231b9957a31a 100644 Binary files a/apache-log4j-2.11.1-src.tar.gz and b/apache-log4j-2.13.2-src.tar.gz differ diff --git a/log4j.spec b/log4j.spec index e1262ccf10c10fab96701d411d5d4f336cb22602..9b090959015e08db8d55aea4259731f797932e79 100644 --- a/log4j.spec +++ b/log4j.spec @@ -1,151 +1,151 @@ -Name: log4j -Version: 2.11.1 -Release: 2 -Summary: Java logging package -BuildArch: noarch -License: ASL 2.0 -URL: http://logging.apache.org/log4j -Source0: http://archive.apache.org/dist/logging/log4j/%{version}/apache-log4j-%{version}-src.tar.gz -BuildRequires: mvn(com.fasterxml.jackson.core:jackson-databind) maven-local mvn(org.osgi:osgi.core) -BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) mvn(org.apache.commons:commons-compress) -BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin) mvn(org.fusesource.jansi:jansi) -BuildRequires: mvn(org.slf4j:slf4j-api) mvn(com.lmax:disruptor) mvn(org.jctools:jctools-core) -BuildRequires: mvn(com.sun.mail:javax.mail) mvn(org.apache.logging:logging-parent:pom:) -BuildRequires: mvn(com.fasterxml.jackson.core:jackson-core) mvn(org.slf4j:slf4j-ext) -BuildRequires: mvn(com.fasterxml.jackson.dataformat:jackson-dataformat-yaml) mvn(sun.jdk:jconsole) -BuildRequires: mvn(com.fasterxml.jackson.dataformat:jackson-dataformat-xml) mvn(org.zeromq:jeromq) -BuildRequires: mvn(org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec) mvn(org.slf4j:slf4j-ext) -BuildRequires: mvn(com.datastax.cassandra:cassandra-driver-core) mvn(org.osgi:osgi.core) -BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin) mvn(com.lmax:disruptor) -BuildRequires: mvn(com.fasterxml.jackson.core:jackson-databind) mvn(org.slf4j:slf4j-api) -BuildRequires: mvn(org.eclipse.persistence:javax.persistence) mvn(com.sun.mail:javax.mail) -BuildRequires: mvn(com.fasterxml.jackson.core:jackson-core) mvn(org.jctools:jctools-core) -BuildRequires: mvn(org.apache.logging:logging-parent:pom:) mvn(javax.servlet.jsp:jsp-api) -BuildRequires: mvn(com.fasterxml.woodstox:woodstox-core) mvn(org.lightcouch:lightcouch) -BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) mvn(org.fusesource.jansi:jansi) -BuildRequires: mvn(org.apache.commons:commons-compress) mvn(org.eclipse.jetty:jetty-util) -BuildRequires: mvn(org.apache.tomcat:tomcat-catalina) mvn(org.apache.commons:commons-csv) -BuildRequires: mvn(commons-logging:commons-logging) mvn(javax.servlet:javax.servlet-api) -Obsoletes: log4j-osgi < 2.9.1-4 log4j-liquibase < 2.9.1-4 - +Name: log4j +Version: 2.13.2 +Release: 1 +Summary: Java logging package +License: Apache-2.0 +URL: http://logging.apache.org/%{name} +Source0: http://archive.apache.org/dist/logging/%{name}/%{version}/apache-%{name}-%{version}-src.tar.gz +Patch1: logging-log4j-Remove-unsupported-EventDataConverter.patch +BuildRequires: fdupes maven-local mvn(com.fasterxml.jackson.core:jackson-core) +BuildRequires: mvn(com.fasterxml.jackson.core:jackson-databind) mvn(com.lmax:disruptor) +BuildRequires: mvn(com.sun.mail:javax.mail) mvn(org.apache.commons:commons-compress) +BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) +BuildRequires: mvn(org.apache.logging:logging-parent:pom:) +BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin) +BuildRequires: mvn(org.fusesource.jansi:jansi) mvn(org.jctools:jctools-core) +BuildRequires: mvn(org.osgi:osgi.core) mvn(org.slf4j:slf4j-api) mvn(org.slf4j:slf4j-ext) +Obsoletes: log4j-mini < %{version}-%{release} +BuildArch: noarch +BuildRequires: mvn(com.datastax.cassandra:cassandra-driver-core) +BuildRequires: mvn(com.fasterxml.jackson.dataformat:jackson-dataformat-xml) +BuildRequires: mvn(com.fasterxml.jackson.dataformat:jackson-dataformat-yaml) +BuildRequires: mvn(com.fasterxml.woodstox:woodstox-core) mvn(commons-logging:commons-logging) +BuildRequires: mvn(javax.servlet.jsp:jsp-api) mvn(javax.servlet:javax.servlet-api) +BuildRequires: mvn(org.apache.commons:commons-csv) mvn(org.apache.tomcat:tomcat-catalina) +BuildRequires: mvn(org.eclipse.jetty:jetty-util) +BuildRequires: mvn(org.eclipse.persistence:javax.persistence) +BuildRequires: mvn(org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec) +BuildRequires: mvn(org.lightcouch:lightcouch) mvn(org.zeromq:jeromq) mvn(sun.jdk:jconsole) +Requires: javapackages-tools %description -Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, -Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent -problems in Logback’s architecture. - -%package slf4j -Summary: Binding between LOG4J 2 API and SLF4J +Log4j is a tool to help the programmer output log statements to a +variety of output targets. -%description slf4j +%package slf4j +Summary: Binding between LOG4J 2 API and SLF4J +%description slf4j Binding between LOG4J 2 API and SLF4J. -%package osgi -Summary: Apache Log4J Core OSGi Bundles +%package jcl +Summary: Apache Log4j Commons Logging Bridge +%description jcl +Apache Log4j Commons Logging Bridge. -%description osgi +%package osgi +Summary: Apache Log4J Core OSGi Bundles +%description osgi Apache Log4J Core OSGi Bundles. -%package taglib -Summary: Apache Log4j Tag Library - -%description taglib +%package taglib +Summary: Apache Log4j Tag Library +%description taglib Apache Log4j Tag Library for Web Applications. -%package jcl -Summary: Apache Log4j Commons Logging Bridge - -%description jcl -Apache Log4j Commons Logging Bridge. - -%package jmx-gui -Summary: Apache Log4j JMX GUI -Requires: java-devel +%package jmx-gui +Summary: Apache Log4j JMX GUI +Requires: java-devel +%description jmx-gui +Swing-based client for remotely editing the log4j configuration and remotely +monitoring StatusLogger output. Includes a JConsole plug-in. -%description jmx-gui -JMX GUI provides a Swing-based client for remotely editing the log4j configuration -and remotely monitoring StatusLogger output. The JMX GUI can be run as a stand-alone -application or as a JConsole plug-in. - -%package web -Summary: Apache Log4j Web - -%description web +%package web +Summary: Apache Log4j Web +%description web Support for Log4j in a web servlet container. -%package bom -Summary: Apache Log4j BOM - -%description bom +%package bom +Summary: Apache Log4j BOM +%description bom Apache Log4j 2 Bill of Material -%package nosql -Summary: Apache Log4j NoSql - -%description nosql +%package nosql +Summary: Apache Log4j NoSql +%description nosql Use NoSQL databases such as MongoDB and CouchDB to append log messages. %package help -Summary: Documentation for log4j -Obsoletes: log4j-manual < %{version} log4j-javadoc < %{version}-%{release} -Provides: log4j-javadoc = %{version}-%{release} +Summary: API documentation for %{name} +Obsoletes: %{name}-manual < %{version} +Provides: log4j-javadoc = %{version}-%{release} %description help Documentation for log4j. %prep -%autosetup -n apache-log4j-%{version}-src +%autosetup -n apache-log4j-%{version}-src -p1 %pom_remove_plugin -r :maven-site-plugin %pom_remove_plugin -r :maven-remote-resources-plugin %pom_remove_plugin -r :maven-doap-plugin %pom_remove_plugin -r :maven-source-plugin %pom_remove_plugin -r :maven-toolchains-plugin +%pom_remove_plugin -r :revapi-maven-plugin find -name "*.jar" -delete find -name "*.class" -delete rm -rf docs/api -%pom_disable_module log4j-samples -%pom_disable_module log4j-distribution -%pom_disable_module log4j-flume-ng -%pom_disable_module log4j-perf -%pom_disable_module log4j-api-java9 -%pom_disable_module log4j-core-java9 -%pom_remove_dep -r :log4j-api-java9 -%pom_remove_dep -r :log4j-core-java9 +%pom_disable_module %{name}-distribution +%pom_disable_module %{name}-samples +%pom_disable_module %{name}-flume-ng +%pom_disable_module %{name}-perf +%pom_disable_module %{name}-api-java9 +%pom_disable_module %{name}-core-java9 +%pom_remove_dep -r :%{name}-api-java9 +%pom_remove_dep -r :%{name}-core-java9 %pom_remove_plugin -r :maven-dependency-plugin find log4j-core/ -name DisruptorBlockingQueueFactory.java -delete %pom_remove_dep -r com.conversantmedia:disruptor rm -r log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka %pom_remove_dep -r :kafka-clients -%pom_disable_module log4j-liquibase -%pom_disable_module log4j-slf4j18-impl -%pom_disable_module log4j-jdbc-dbcp2 -%pom_disable_module log4j-mongodb2 -%pom_disable_module log4j-mongodb3 -%pom_remove_dep :jconsole log4j-jmx-gui -%pom_add_dep sun.jdk:jconsole log4j-jmx-gui +%pom_disable_module %{name}-liquibase +%pom_disable_module %{name}-slf4j18-impl +%pom_disable_module %{name}-jdbc-dbcp2 +%pom_disable_module %{name}-mongodb2 +%pom_disable_module %{name}-mongodb3 +%pom_remove_dep :jconsole %{name}-jmx-gui +%pom_add_dep sun.jdk:jconsole %{name}-jmx-gui %pom_change_dep -r org.osgi:org.osgi.core org.osgi:osgi.core -%pom_remove_plugin :apache-rat-plugin log4j-bom +%pom_remove_plugin :apache-rat-plugin %{name}-bom %pom_remove_plugin :maven-failsafe-plugin -%mvn_alias :log4j-1.2-api log4j:log4j -%mvn_file ':{log4j-1.2-api}' log4j/@1 log4j -%mvn_package ':log4j-slf4j-impl' slf4j -%mvn_package ':log4j-to-slf4j' slf4j -%mvn_package ':log4j-taglib' taglib -%mvn_package ':log4j-jcl' jcl -%mvn_package ':log4j-jmx-gui' jmx-gui -%mvn_package ':log4j-web' web -%mvn_package ':log4j-bom' bom -%mvn_package ':log4j-cassandra' nosql -%mvn_package ':log4j-couchdb' nosql -%mvn_package :log4j-core-its __noinstall +%pom_disable_module %{name}-iostreams +%pom_disable_module %{name}-jul +%pom_disable_module %{name}-core-its +%pom_disable_module %{name}-jpa +%pom_disable_module %{name}-appserver +%pom_disable_module %{name}-spring-cloud-config +%pom_disable_module %{name}-kubernetes +%pom_disable_module %{name}-jpl +%{mvn_file} ':{%{name}-1.2-api}' %{name}/@1 %{name} +%{mvn_package} ':%{name}-slf4j-impl' slf4j +%{mvn_package} ':%{name}-to-slf4j' slf4j +%{mvn_package} ':%{name}-taglib' taglib +%{mvn_package} ':%{name}-jcl' jcl +%{mvn_package} ':%{name}-jmx-gui' jmx-gui +%{mvn_package} ':%{name}-web' web +%{mvn_package} ':%{name}-bom' bom +%{mvn_package} ':%{name}-cassandra' nosql +%{mvn_package} ':%{name}-couchdb' nosql +%{mvn_package} :log4j-core-its __noinstall + %build -%mvn_build -f +%{mvn_build} -f -- -Dsource=8 + %install %mvn_install -%jpackage_script org.apache.logging.log4j.jmx.gui.ClientGUI '' '' log4j/log4j-jmx-gui:log4j/log4j-core log4j-jmx false +%fdupes -s %{buildroot}%{_javadocdir} +%jpackage_script org.apache.logging.log4j.jmx.gui.ClientGUI '' '' %{name}/%{name}-jmx-gui:%{name}/%{name}-core %{name}-jmx false %files -f .mfiles %doc LICENSE.txt NOTICE.txt -%dir %{_javadir}/log4j +%dir %{_javadir}/%{name} %files slf4j -f .mfiles-slf4j @@ -160,10 +160,15 @@ rm -r log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka %files nosql -f .mfiles-nosql %files jmx-gui -f .mfiles-jmx-gui -%{_bindir}/log4j-jmx +%{_bindir}/%{name}-jmx %files help -f .mfiles-javadoc +%license LICENSE.txt +%doc NOTICE.txt %changelog +* Wed Oct 21 2020 wangyue - 2.13.2-1 +- Upgrade to 2.13.2 to fix CVE-2020-9488 + * Mon Dec 23 2019 Ling Yang - 2.11.1-2 - Package init diff --git a/log4j.yaml b/log4j.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c0c3c2845ab5de70482342943ba07465a8581597 --- /dev/null +++ b/log4j.yaml @@ -0,0 +1,5 @@ +git_url: https://github.com/apache/logging-log4j2 +version_control: github +src_repo: apache/logging-log4j2 +tag_prefix: "^rel/" +seperator: "." diff --git a/logging-log4j-Remove-unsupported-EventDataConverter.patch b/logging-log4j-Remove-unsupported-EventDataConverter.patch new file mode 100644 index 0000000000000000000000000000000000000000..041bfae0e928d847d3da4e1f328fc9c9cd056aed --- /dev/null +++ b/logging-log4j-Remove-unsupported-EventDataConverter.patch @@ -0,0 +1,287 @@ +From b017736fa1b58377b8bf1b89599b274a9cfb9956 Mon Sep 17 00:00:00 2001 +From: Dinesh Prasanth M K +Date: Fri, 31 Jan 2020 13:00:05 -0500 +Subject: [PATCH] Remove unsupported EventDataConverter + +This deletes the EventDataConverter entirely from log4j-slf4j-impl +entirely because EventData is not supported in 1.8. + +Signed-off-by: Dinesh Prasanth M K +--- + .../logging/slf4j/EventDataConverter.java | 50 -------------- + .../org/apache/logging/slf4j/Log4jLogger.java | 22 +----- + .../org/apache/logging/slf4j/LoggerTest.java | 21 ------ + .../apache/logging/slf4j/OptionalTest.java | 69 ------------------- + .../src/test/resources/log4j-test1.xml | 7 -- + 5 files changed, 1 insertion(+), 168 deletions(-) + delete mode 100644 log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/EventDataConverter.java + delete mode 100644 log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java + +diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/EventDataConverter.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/EventDataConverter.java +deleted file mode 100644 +index 620232a..0000000 +--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/EventDataConverter.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 java.util.Map; +- +-import org.apache.logging.log4j.message.Message; +-import org.apache.logging.log4j.message.ParameterizedMessage; +-import org.apache.logging.log4j.message.StructuredDataMessage; +-import org.slf4j.ext.EventData; +- +-/** +- * +- */ +-public class EventDataConverter { +- +- public Message convertEvent(final String message, final Object[] objects, final Throwable throwable) { +- try { +- final EventData data = objects != null && objects[0] instanceof EventData ? +- (EventData) objects[0] : new EventData(message); +- final StructuredDataMessage msg = +- new StructuredDataMessage(data.getEventId(), data.getMessage(), data.getEventType()); +- for (final Map.Entry entry : data.getEventMap().entrySet()) { +- final String key = entry.getKey(); +- if (EventData.EVENT_TYPE.equals(key) || EventData.EVENT_ID.equals(key) +- || EventData.EVENT_MESSAGE.equals(key)) { +- continue; +- } +- msg.put(key, String.valueOf(entry.getValue())); +- } +- return msg; +- } catch (final Exception ex) { +- return new ParameterizedMessage(message, objects, throwable); +- } +- } +-} +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 +index 1fa8080..90cfe4e 100644 +--- 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 +@@ -27,9 +27,7 @@ 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.apache.logging.log4j.util.LoaderUtil; + import org.slf4j.Marker; +-import org.slf4j.MarkerFactory; + import org.slf4j.impl.StaticMarkerBinder; + import org.slf4j.spi.LocationAwareLogger; + +@@ -39,18 +37,13 @@ import org.slf4j.spi.LocationAwareLogger; + public class Log4jLogger implements LocationAwareLogger, Serializable { + + public static final String FQCN = Log4jLogger.class.getName(); +- + private static final long serialVersionUID = 7869000638091304316L; +- private static final Marker EVENT_MARKER = MarkerFactory.getMarker("EVENT"); +- private static final EventDataConverter CONVERTER = createConverter(); + +- private final boolean eventLogger; + private transient ExtendedLogger logger; + private final String name; + + public Log4jLogger(final ExtendedLogger logger, final String name) { + this.logger = logger; +- this.eventLogger = "EventLogger".equals(name); + this.name = name; + } + +@@ -363,9 +356,7 @@ public class Log4jLogger implements LocationAwareLogger, Serializable { + return; + } + final Message msg; +- if (CONVERTER != null && eventLogger && marker != null && marker.contains(EVENT_MARKER)) { +- msg = CONVERTER.convertEvent(message, params, throwable); +- } else if (params == null) { ++ if (params == null) { + msg = new SimpleMessage(message); + } else { + msg = new ParameterizedMessage(message, params, throwable); +@@ -410,15 +401,6 @@ public class Log4jLogger implements LocationAwareLogger, Serializable { + aOutputStream.defaultWriteObject(); + } + +- private static EventDataConverter createConverter() { +- try { +- LoaderUtil.loadClass("org.slf4j.ext.EventData"); +- return new EventDataConverter(); +- } catch (final ClassNotFoundException cnfe) { +- return null; +- } +- } +- + private static Level getLevel(final int i) { + switch (i) { + case TRACE_INT: +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 +index 0524074..c60f1ad 100644 +--- 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 +@@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull; + import static org.junit.Assert.assertTrue; + + import java.util.List; +-import java.util.Locale; + + import org.apache.logging.log4j.junit.LoggerContextRule; + import org.apache.logging.log4j.test.appender.ListAppender; +@@ -34,8 +33,6 @@ import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + import org.slf4j.MDC; + import org.slf4j.Marker; +-import org.slf4j.ext.EventData; +-import org.slf4j.ext.EventLogger; + import org.slf4j.ext.XLogger; + import org.slf4j.ext.XLoggerFactory; + import org.slf4j.spi.LocationAwareLogger; +@@ -145,23 +142,6 @@ public class LoggerTest { + verify("List", "o.a.l.s.LoggerTest Hello, Log4j Log4j {} MDC{}" + Strings.LINE_SEPARATOR); + } + +- @Test +- public void testEventLogger() { +- MDC.put("loginId", "JohnDoe"); +- MDC.put("ipAddress", "192.168.0.120"); +- MDC.put("locale", Locale.US.getDisplayName()); +- final EventData data = new EventData(); +- data.setEventType("Transfer"); +- data.setEventId("Audit@18060"); +- data.setMessage("Transfer Complete"); +- data.put("ToAccount", "123456"); +- data.put("FromAccount", "123457"); +- data.put("Amount", "200.00"); +- EventLogger.logEvent(data); +- MDC.clear(); +- verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Strings.LINE_SEPARATOR); +- } +- + private void verify(final String name, final String expected) { + final ListAppender listApp = ctx.getListAppender(name); + assertNotNull("Missing Appender", listApp); +@@ -177,6 +157,5 @@ public class LoggerTest { + public void cleanup() { + MDC.clear(); + ctx.getListAppender("List").clear(); +- ctx.getListAppender("EventLogger").clear(); + } + } +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 a6e9fd5..0000000 +--- 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 java.util.List; +- +-import org.apache.logging.log4j.junit.LoggerContextRule; +-import org.apache.logging.log4j.test.appender.ListAppender; +-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; +- +-import static org.junit.Assert.*; +- +-/** +- * +- */ +-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 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/resources/log4j-test1.xml b/log4j-slf4j-impl/src/test/resources/log4j-test1.xml +index a64bdfa..07a2be6 100644 +--- a/log4j-slf4j-impl/src/test/resources/log4j-test1.xml ++++ b/log4j-slf4j-impl/src/test/resources/log4j-test1.xml +@@ -6,9 +6,6 @@ + + + +- +- +- + + + +@@ -24,10 +21,6 @@ + + + +- +- +- > +- + + +