From 00a68ca27f8e83c2727039b03a1c6ca3151af734 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 Feb 2012 23:55:13 +0000 Subject: [PATCH 001/363] Make new home for Log4j2 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1241269 13f79535-47bb-0310-9956-ffa450edef68 From 2f96fb230cf5272d6d47b7496bba82fb81922ffa Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 7 Jan 2013 00:29:30 +0000 Subject: [PATCH 002/363] Add Log4j 2 to SLF4J adapter git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1429628 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 187 ++++++++++++++++++ .../apache/logging/slf4j/MDCContextMap.java | 59 ++++++ .../org/apache/logging/slf4j/SLF4JLogger.java | 152 ++++++++++++++ .../logging/slf4j/SLF4JLoggerContext.java | 54 +++++ .../slf4j/SLF4JLoggerContextFactory.java | 31 +++ .../apache/logging/slf4j/package-info.java | 20 ++ .../META-INF/log4j-provider.properties | 19 ++ log4j-to-slf4j/src/site/site.xml | 27 +++ log4j-to-slf4j/src/site/xdoc/index.xml | 53 +++++ .../org/apache/logging/slf4j/LoggerTest.java | 174 ++++++++++++++++ .../src/test/resources/logback-slf4j.xml | 13 ++ 11 files changed, 789 insertions(+) create mode 100644 log4j-to-slf4j/pom.xml create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java create mode 100644 log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties create mode 100644 log4j-to-slf4j/src/site/site.xml create mode 100644 log4j-to-slf4j/src/site/xdoc/index.xml create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java create mode 100644 log4j-to-slf4j/src/test/resources/logback-slf4j.xml diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml new file mode 100644 index 0000000..e6ead03 --- /dev/null +++ b/log4j-to-slf4j/pom.xml @@ -0,0 +1,187 @@ + + + 4.0.0 + + org.apache.logging.log4j + log4j + 2.0-beta4-SNAPSHOT + ../ + + org.apache.logging.log4j.adapters + log4j-to-slf4j + jar + Apache Log4j to SLF4J Adapter + Binding between LOG4J 2 API and SLF4J + + ${basedir}/.. + SLF4J Documentation + /log4j-to-slf4j + + + + org.slf4j + slf4j-api + + + org.apache.logging.log4j + log4j-api + + + ch.qos.logback + logback-core + test + + + ch.qos.logback + logback-core + test-jar + test + + + ch.qos.logback + logback-classic + test + + + junit + junit + test + + + + + + org.apache.maven.plugins + maven-changes-plugin + ${changes.plugin.version} + + + + changes-report + + + + + %URL%/show_bug.cgi?id=%ISSUE% + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.7 + + + ${log4jParentDir}/checkstyle.xml + ${log4jParentDir}/checkstyle-suppressions.xml + false + basedir=${basedir} + licensedir=${log4jParentDir}/checkstyle-header.txt + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${javadoc.plugin.version} + + Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.
+ Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, + and the Apache Log4j logo are trademarks of The Apache Software Foundation.

]]>
+ + false + true + + + issue + a + JIRA issue: + + + doubt + a + Troublesome: + + + compare + a + Compare with: + + +
+ + + non-aggregate + + javadoc + + + +
+ + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + Normal + Default + findbugs-exclude-filter.xml + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + + non-aggregate + + jxr + + + + aggregate + + aggregate + + + + + + org.apache.maven.plugins + maven-pmd-plugin + ${pmd.plugin.version} + + 1.5 + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.2 + + + + + + + +
+
+
+ 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 new file mode 100644 index 0000000..67af884 --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java @@ -0,0 +1,59 @@ +/* + * 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.spi.ThreadContextMap; +import org.slf4j.MDC; + +import java.util.Map; + +/** + * Bind the ThreadContextMap to the SLF4J MDC. + */ +public class MDCContextMap implements ThreadContextMap { + public void put(String key, String value) { + MDC.put(key, value); + } + + public String get(String key) { + return MDC.get(key); + } + + public void remove(String key) { + MDC.remove(key); + } + + public void clear() { + MDC.clear(); + } + + public boolean containsKey(String key) { + return MDC.getCopyOfContextMap().containsKey(key); + } + + public Map getContext() { + return MDC.getCopyOfContextMap(); + } + + public Map get() { + return MDC.getCopyOfContextMap(); + } + + public boolean isEmpty() { + return MDC.getCopyOfContextMap().isEmpty(); + } +} 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 new file mode 100644 index 0000000..547315c --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java @@ -0,0 +1,152 @@ +/* + * 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.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.slf4j.MarkerFactory; +import org.slf4j.spi.LocationAwareLogger; + +/** + * + */ +public class SLF4JLogger extends AbstractLogger { + + private final org.slf4j.Logger logger; + private final LocationAwareLogger locationAwareLogger; + + public SLF4JLogger(final String name, final org.slf4j.Logger logger) { + super(name); + this.logger = logger; + this.locationAwareLogger = logger instanceof LocationAwareLogger ? (LocationAwareLogger) logger : null; + } + + 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; + } + + @Override + protected void log(Marker marker, String fqcn, Level level, Message data, Throwable t) { + if (locationAwareLogger != null) { + if (data instanceof LoggerNameAwareMessage) { + ((LoggerNameAwareMessage) data).setLoggerName(getName()); + } + locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), data.getFormattedMessage(), + data.getParameters(), t); + } else { + switch (level) { + case DEBUG : + logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + case TRACE : + logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + case INFO : + logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + case WARN : + logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + case ERROR : + logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + default : + logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + } + } + } + + private org.slf4j.Marker getMarker(Marker marker) { + if (marker == null) { + return null; + } + Marker parent = marker.getParent(); + org.slf4j.Marker parentMarker = parent == null ? null : getMarker(parent); + org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName()); + if (parentMarker != null && !slf4jMarker.contains(parentMarker)) { + slf4jMarker.add(parentMarker); + } + return slf4jMarker; + } + + private int convertLevel(Level level) { + switch (level) { + 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 + protected boolean isEnabled(Level level, Marker marker, String data) { + return isEnabledFor(level, marker); + } + + @Override + protected boolean isEnabled(Level level, Marker marker, String data, Throwable t) { + return isEnabledFor(level, marker); + } + + @Override + protected boolean isEnabled(Level level, Marker marker, String data, Object... p1) { + return isEnabledFor(level, marker); + } + + @Override + protected boolean isEnabled(Level level, Marker marker, Object data, Throwable t) { + return isEnabledFor(level, marker); + } + + @Override + protected boolean isEnabled(Level level, Marker marker, Message data, Throwable t) { + return isEnabledFor(level, marker); + } + + private boolean isEnabledFor(Level level, Marker marker) { + org.slf4j.Marker slf4jMarker = getMarker(marker); + switch (level) { + 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); + + } + } + + public org.slf4j.Logger getLogger() { + return locationAwareLogger != null ? locationAwareLogger : logger; + } + +} 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 new file mode 100644 index 0000000..d25e32c --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java @@ -0,0 +1,54 @@ +/* + * 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.Logger; +import org.apache.logging.log4j.message.MessageFactory; +import org.apache.logging.log4j.spi.LoggerContext; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * + */ +public class SLF4JLoggerContext implements LoggerContext { + private final ConcurrentMap loggers = new ConcurrentHashMap(); + + public Object getExternalContext() { + return null; + } + + public Logger getLogger(String name) { + if (!loggers.containsKey(name)) { + loggers.putIfAbsent(name, new SLF4JLogger(name, LoggerFactory.getLogger(name))); + } + return loggers.get(name); + } + + public Logger getLogger(String name, MessageFactory messageFactory) { + if (!loggers.containsKey(name)) { + loggers.putIfAbsent(name, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); + } + return loggers.get(name); + } + + public boolean hasLogger(String name) { + return loggers.containsKey(name); + } +} 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 new file mode 100644 index 0000000..d9c9c4a --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java @@ -0,0 +1,31 @@ +/* + * 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.spi.LoggerContext; +import org.apache.logging.log4j.spi.LoggerContextFactory; + +/** + * + */ +public class SLF4JLoggerContextFactory implements LoggerContextFactory { + private static LoggerContext context = new SLF4JLoggerContext(); + + public LoggerContext getContext(final String FQCN, final ClassLoader loader, final boolean currentContext) { + return context; + } +} 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 new file mode 100644 index 0000000..092c09a --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ +package org.apache.logging.slf4j; diff --git a/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties b/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties new file mode 100644 index 0000000..72b3a0b --- /dev/null +++ b/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties @@ -0,0 +1,19 @@ +# 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. + +LoggerContextFactory = org.apache.logging.slf4j.SLF4JLoggerContextFactory +Log4jAPIVersion = 2.0.0 +FactoryPriority= 15 +ThreadContextMap = org.apache.logging.slf4j.MDCContextMap \ No newline at end of file diff --git a/log4j-to-slf4j/src/site/site.xml b/log4j-to-slf4j/src/site/site.xml new file mode 100644 index 0000000..09a9352 --- /dev/null +++ b/log4j-to-slf4j/src/site/site.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + diff --git a/log4j-to-slf4j/src/site/xdoc/index.xml b/log4j-to-slf4j/src/site/xdoc/index.xml new file mode 100644 index 0000000..8462ab0 --- /dev/null +++ b/log4j-to-slf4j/src/site/xdoc/index.xml @@ -0,0 +1,53 @@ + + + + + + Log4j to SLF4J Adapter + Ralph Goers + + + +
+ +

+ The Log4j 2 to SLF4J Adapter allows applications coded to the Log4j 2 API to be routed to SLF4J. + Use of this adapter may cause some loss of performance as the Log4j 2 Messages must be formatted + before they can be passed to SLF4J. With Log4j 2 as the implementation these would normally be + formatted only when they are accessed by a Filter or Appender. +

+ +
+ +
+

+ The Log4j 2 to SLF4J adapter requires at least Java 5. Use of this adapter together with the + SLF4J bridge should never be attempted as it will cause a events to endlessly be routed between + SLF4J and Log4j 2. +

+
+ +
+

+ Include this jar, the SLF4J jar(s) and an SLF4J logging implementation jar together. Configure + the logging implementation as required. +

+
+ + +
\ No newline at end of file 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 new file mode 100644 index 0000000..eb6750a --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java @@ -0,0 +1,174 @@ + +/* +* 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 static org.junit.Assert.assertTrue; + +import java.util.Date; +import java.util.List; + +import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.joran.spi.JoranException; +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 ch.qos.logback.core.testUtil.StringListAppender; +import ch.qos.logback.classic.LoggerContext; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class LoggerTest { + + private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; + private static Logger logger; + private static org.slf4j.Logger slf4jLogger; + private static LoggerContext context; + private static Logger root; + private static ch.qos.logback.classic.Logger rootLogger; + private static StringListAppender list; + + @BeforeClass + public static void setupClass() throws Exception { + slf4jLogger = LoggerFactory.getLogger(LoggerTest.class); + context = ((ch.qos.logback.classic.Logger) slf4jLogger).getLoggerContext(); + configure(CONFIG); + logger = LogManager.getLogger(LoggerTest.class); + assertTrue("Incorrect SLF4J Logger", ((SLF4JLogger) logger).getLogger() == slf4jLogger); + root = LogManager.getLogger(""); + rootLogger = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + list = (StringListAppender) rootLogger.getAppender("LIST"); + rootLogger.detachAppender("console"); + } + + private static void configure(String file) throws JoranException { + JoranConfigurator jc = new JoranConfigurator(); + jc.setContext(context); + jc.doConfigure(file); + } + + @Before + public void before() { + list.strList.clear(); + } + + @Test + public void basicFlow() { + logger.entry(); + logger.exit(); + assertTrue("Incorrect number of events. Expected 2, actual " + list.strList.size(), list.strList.size() == 2); + } + + @Test + public void simpleFlow() { + logger.entry(CONFIG); + logger.exit(0); + assertTrue("Incorrect number of events. Expected 2, actual " + list.strList.size(), list.strList.size() == 2); + } + + @Test + public void throwing() { + logger.throwing(new IllegalArgumentException("Test Exception")); + assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + } + + @Test + public void catching() { + try { + throw new NullPointerException(); + } catch (final Exception e) { + logger.catching(e); + } + assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + } + + @Test + public void debug() { + logger.debug("Debug message"); + assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + } + + @Test + public void getLogger_String_MessageFactoryMismatch() { + final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatch", + StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE); + testLogger.debug("%,d", Integer.MAX_VALUE); + assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0)); + } + + @Test + public void getLogger_String_MessageFactoryMismatchNull() { + final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull", + StringFormatterMessageFactory.INSTANCE, null); + testLogger.debug("%,d", Integer.MAX_VALUE); + assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0)); + } + + private Logger testMessageFactoryMismatch(final String name, final MessageFactory messageFactory1, final MessageFactory messageFactory2) { + final Logger testLogger = (Logger) LogManager.getLogger(name, messageFactory1); + assertNotNull(testLogger); + assertEquals(messageFactory1, testLogger.getMessageFactory()); + final Logger testLogger2 = (Logger) LogManager.getLogger(name, messageFactory2); + assertEquals(messageFactory1, testLogger2.getMessageFactory()); + return testLogger; + } + + @Test + public void debugObject() { + logger.debug(new Date()); + assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + } + + @Test + public void debugWithParms() { + logger.debug("Hello, {}", "World"); + assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + } + + @Test + public void testImpliedThrowable() { + logger.debug("This is a test", new Throwable("Testing")); + final List msgs = list.strList; + assertTrue("Incorrect number of messages. Expected 1, actual " + msgs.size(), msgs.size() == 1); + String expected = "java.lang.Throwable: Testing"; + assertTrue("Incorrect message data", msgs.get(0).contains(expected)); + } + @Test + public void mdc() { + ThreadContext.put("TestYear", new Integer(2010).toString()); + logger.debug("Debug message"); + ThreadContext.clear(); + logger.debug("Debug message"); + assertTrue("Incorrect number of events. Expected 2, actual " + list.strList.size(), list.strList.size() == 2); + assertTrue("Incorrect year", list.strList.get(0).startsWith("2010")); + } +} + diff --git a/log4j-to-slf4j/src/test/resources/logback-slf4j.xml b/log4j-to-slf4j/src/test/resources/logback-slf4j.xml new file mode 100644 index 0000000..ad45676 --- /dev/null +++ b/log4j-to-slf4j/src/test/resources/logback-slf4j.xml @@ -0,0 +1,13 @@ + + + + + + %X{TestYear}%msg + + + + + + + From 96d07a32704a33e368176a6629c317b4cbc7ead5 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 10 Jan 2013 15:34:39 +0000 Subject: [PATCH 003/363] Remove unnecessary casts. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1431434 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index eb6750a..66644b7 100644 --- 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 @@ -133,10 +133,10 @@ public void getLogger_String_MessageFactoryMismatchNull() { } private Logger testMessageFactoryMismatch(final String name, final MessageFactory messageFactory1, final MessageFactory messageFactory2) { - final Logger testLogger = (Logger) LogManager.getLogger(name, messageFactory1); + final Logger testLogger = LogManager.getLogger(name, messageFactory1); assertNotNull(testLogger); assertEquals(messageFactory1, testLogger.getMessageFactory()); - final Logger testLogger2 = (Logger) LogManager.getLogger(name, messageFactory2); + final Logger testLogger2 = LogManager.getLogger(name, messageFactory2); assertEquals(messageFactory1, testLogger2.getMessageFactory()); return testLogger; } From 0a82c864ed4a6ab6861bc3a715fbe1c42f3c8297 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 10 Jan 2013 15:40:48 +0000 Subject: [PATCH 004/363] Remove unused imports. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1431439 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 1 - 1 file changed, 1 deletion(-) 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 index 66644b7..0873849 100644 --- 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 @@ -35,7 +35,6 @@ import org.apache.logging.log4j.message.StringFormatterMessageFactory; import ch.qos.logback.core.testUtil.StringListAppender; import ch.qos.logback.classic.LoggerContext; -import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; From b30e3bca6498e33769856d62e3bfdb03495ac6ba Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 10 Jan 2013 20:23:34 +0000 Subject: [PATCH 005/363] Add final modifier to local variables. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1431609 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/logging/slf4j/SLF4JLogger.java | 8 ++++---- .../test/java/org/apache/logging/slf4j/LoggerTest.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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 index 547315c..d269ad3 100644 --- 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 @@ -75,9 +75,9 @@ private org.slf4j.Marker getMarker(Marker marker) { if (marker == null) { return null; } - Marker parent = marker.getParent(); - org.slf4j.Marker parentMarker = parent == null ? null : getMarker(parent); - org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName()); + final Marker parent = marker.getParent(); + final org.slf4j.Marker parentMarker = parent == null ? null : getMarker(parent); + final org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName()); if (parentMarker != null && !slf4jMarker.contains(parentMarker)) { slf4jMarker.add(parentMarker); } @@ -127,7 +127,7 @@ protected boolean isEnabled(Level level, Marker marker, Message data, Throwable } private boolean isEnabledFor(Level level, Marker marker) { - org.slf4j.Marker slf4jMarker = getMarker(marker); + final org.slf4j.Marker slf4jMarker = getMarker(marker); switch (level) { case DEBUG : return logger.isDebugEnabled(slf4jMarker); 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 index 0873849..16a9fd0 100644 --- 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 @@ -67,7 +67,7 @@ public static void setupClass() throws Exception { } private static void configure(String file) throws JoranException { - JoranConfigurator jc = new JoranConfigurator(); + final JoranConfigurator jc = new JoranConfigurator(); jc.setContext(context); jc.doConfigure(file); } @@ -157,7 +157,7 @@ public void testImpliedThrowable() { logger.debug("This is a test", new Throwable("Testing")); final List msgs = list.strList; assertTrue("Incorrect number of messages. Expected 1, actual " + msgs.size(), msgs.size() == 1); - String expected = "java.lang.Throwable: Testing"; + final String expected = "java.lang.Throwable: Testing"; assertTrue("Incorrect message data", msgs.get(0).contains(expected)); } @Test From 76ba16241a1297eb410879e75d6136aa9c35012f Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Fri, 11 Jan 2013 05:33:44 +0000 Subject: [PATCH 006/363] Add final modifier to method parameters. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1431898 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/logging/slf4j/MDCContextMap.java | 8 ++++---- .../org/apache/logging/slf4j/SLF4JLogger.java | 18 +++++++++--------- .../logging/slf4j/SLF4JLoggerContext.java | 6 +++--- .../org/apache/logging/slf4j/LoggerTest.java | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) 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 index 67af884..5eabba4 100644 --- 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 @@ -25,15 +25,15 @@ * Bind the ThreadContextMap to the SLF4J MDC. */ public class MDCContextMap implements ThreadContextMap { - public void put(String key, String value) { + public void put(final String key, final String value) { MDC.put(key, value); } - public String get(String key) { + public String get(final String key) { return MDC.get(key); } - public void remove(String key) { + public void remove(final String key) { MDC.remove(key); } @@ -41,7 +41,7 @@ public void clear() { MDC.clear(); } - public boolean containsKey(String key) { + public boolean containsKey(final String key) { return MDC.getCopyOfContextMap().containsKey(key); } 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 index d269ad3..307acff 100644 --- 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 @@ -46,7 +46,7 @@ public SLF4JLogger(final String name, final MessageFactory messageFactory, final } @Override - protected void log(Marker marker, String fqcn, Level level, Message data, Throwable t) { + protected void log(final Marker marker, final String fqcn, final Level level, final Message data, final Throwable t) { if (locationAwareLogger != null) { if (data instanceof LoggerNameAwareMessage) { ((LoggerNameAwareMessage) data).setLoggerName(getName()); @@ -71,7 +71,7 @@ protected void log(Marker marker, String fqcn, Level level, Message data, Throwa } } - private org.slf4j.Marker getMarker(Marker marker) { + private org.slf4j.Marker getMarker(final Marker marker) { if (marker == null) { return null; } @@ -84,7 +84,7 @@ private org.slf4j.Marker getMarker(Marker marker) { return slf4jMarker; } - private int convertLevel(Level level) { + private int convertLevel(final Level level) { switch (level) { case DEBUG : return LocationAwareLogger.DEBUG_INT; @@ -102,31 +102,31 @@ private int convertLevel(Level level) { } @Override - protected boolean isEnabled(Level level, Marker marker, String data) { + protected boolean isEnabled(final Level level, final Marker marker, final String data) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(Level level, Marker marker, String data, Throwable t) { + protected boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(Level level, Marker marker, String data, Object... p1) { + protected boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(Level level, Marker marker, Object data, Throwable t) { + protected boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(Level level, Marker marker, Message data, Throwable t) { + protected boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) { return isEnabledFor(level, marker); } - private boolean isEnabledFor(Level level, Marker marker) { + private boolean isEnabledFor(final Level level, final Marker marker) { final org.slf4j.Marker slf4jMarker = getMarker(marker); switch (level) { case DEBUG : 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 index d25e32c..6f98ec0 100644 --- 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 @@ -34,21 +34,21 @@ public Object getExternalContext() { return null; } - public Logger getLogger(String name) { + public Logger getLogger(final String name) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, LoggerFactory.getLogger(name))); } return loggers.get(name); } - public Logger getLogger(String name, MessageFactory messageFactory) { + public Logger getLogger(final String name, final MessageFactory messageFactory) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); } return loggers.get(name); } - public boolean hasLogger(String name) { + public boolean hasLogger(final String name) { return loggers.containsKey(name); } } 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 index 16a9fd0..873c986 100644 --- 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 @@ -66,7 +66,7 @@ public static void setupClass() throws Exception { rootLogger.detachAppender("console"); } - private static void configure(String file) throws JoranException { + private static void configure(final String file) throws JoranException { final JoranConfigurator jc = new JoranConfigurator(); jc.setContext(context); jc.doConfigure(file); From 5cf2f217c9c8c693ced5f773ae3387a4e3893fdc Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 19 Jan 2013 15:03:30 +0000 Subject: [PATCH 007/363] Fix some of the checkstyle errors that have recently been introduced. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1435569 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/logging/slf4j/SLF4JLogger.java | 9 ++++++++- .../apache/logging/slf4j/SLF4JLoggerContextFactory.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) 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 index 307acff..e516651 100644 --- 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 @@ -46,7 +46,8 @@ public SLF4JLogger(final String name, final MessageFactory messageFactory, final } @Override - protected void log(final Marker marker, final String fqcn, final Level level, final Message data, final Throwable t) { + protected void log(final Marker marker, final String fqcn, final Level level, final Message data, + final Throwable t) { if (locationAwareLogger != null) { if (data instanceof LoggerNameAwareMessage) { ((LoggerNameAwareMessage) data).setLoggerName(getName()); @@ -57,16 +58,22 @@ protected void log(final Marker marker, final String fqcn, final Level level, fi switch (level) { case DEBUG : logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; case TRACE : logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; case INFO : logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; case WARN : logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; case ERROR : logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; default : logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; } } } 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 index d9c9c4a..893610d 100644 --- 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 @@ -25,7 +25,7 @@ public class SLF4JLoggerContextFactory implements LoggerContextFactory { private static LoggerContext context = new SLF4JLoggerContext(); - public LoggerContext getContext(final String FQCN, final ClassLoader loader, final boolean currentContext) { + public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) { return context; } } From 8a3ab27712853e35a19de4e23a82a2ba8f0251fc Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 20 Jan 2013 20:54:05 +0000 Subject: [PATCH 008/363] [maven-release-plugin] prepare release log4j-2.0-beta4 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1435954 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e6ead03..ad1ea57 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta4-SNAPSHOT + 2.0-beta4 ../ org.apache.logging.log4j.adapters From e1cf9659082b26aa8c6e16e4c6539a3a8a769b18 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 20 Jan 2013 20:54:16 +0000 Subject: [PATCH 009/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1435956 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad1ea57..0578c40 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta4 + 2.0-beta5-SNAPSHOT ../ org.apache.logging.log4j.adapters From f9726fbdef44808a3baff9e083eef29d4acbbf18 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 22 Jan 2013 07:21:57 +0000 Subject: [PATCH 010/363] revert release version git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1436775 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0578c40..e6ead03 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta5-SNAPSHOT + 2.0-beta4-SNAPSHOT ../ org.apache.logging.log4j.adapters From 91ad7d9fbc87e2d935d05a11f4e74191622ee385 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 28 Jan 2013 07:43:38 +0000 Subject: [PATCH 011/363] [maven-release-plugin] prepare release log4j-2.0-beta4 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1439284 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e6ead03..ad1ea57 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta4-SNAPSHOT + 2.0-beta4 ../ org.apache.logging.log4j.adapters From 5a33bee8b64df0f38a2711bc8559f1601068c768 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 28 Jan 2013 07:43:58 +0000 Subject: [PATCH 012/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1439286 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad1ea57..0578c40 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta4 + 2.0-beta5-SNAPSHOT ../ org.apache.logging.log4j.adapters From 8dc0c80058ecbf871c20f122ba5112305cee6faf Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 3 Mar 2013 21:42:59 +0000 Subject: [PATCH 013/363] LOG4J2-161 - Modify ClassLoaderContextSelector to use the first ClassLoader in the child parent hierarchy that has a Context with a configuration to allow JSPs to use the WebApp's context and configuration. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1452133 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/logging/slf4j/SLF4JLoggerContextFactory.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 index 893610d..ddf6ef9 100644 --- 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 @@ -19,6 +19,8 @@ import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.LoggerContextFactory; +import java.net.URI; + /** * */ @@ -28,4 +30,9 @@ public class SLF4JLoggerContextFactory implements LoggerContextFactory { public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) { return context; } + + public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext, + URI configLocation) { + return context; + } } From 6c45bd4e2be965e9cf67a3f2e7561c31428ce3a2 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 11 Apr 2013 14:28:39 +0000 Subject: [PATCH 014/363] [LOG4J2-206] Use the same Maven group ID for all artifacts: org.apache.logging.log4j. The group ID org.apache.logging.log4j.adapters is no longer used. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1466901 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0578c40..8a8a0fa 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -23,7 +23,7 @@ 2.0-beta5-SNAPSHOT ../ - org.apache.logging.log4j.adapters + org.apache.logging.log4j log4j-to-slf4j jar Apache Log4j to SLF4J Adapter From 246060a8c54d29979c14e03bb88242875b439396 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 20 Apr 2013 14:55:41 +0000 Subject: [PATCH 015/363] LOG4J2-199 - Fix Site Navigation git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1470168 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/src/site/site.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/log4j-to-slf4j/src/site/site.xml b/log4j-to-slf4j/src/site/site.xml index 09a9352..62632f3 100644 --- a/log4j-to-slf4j/src/site/site.xml +++ b/log4j-to-slf4j/src/site/site.xml @@ -22,6 +22,28 @@ + + + + + + + + + + + + + + + + + + + + + + From 98c70efe6634dfdf4db9103936b2eb53a316aea8 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 20 Apr 2013 21:20:14 +0000 Subject: [PATCH 016/363] [maven-release-plugin] prepare release log4j-2.0-beta5 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1470231 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 8a8a0fa..4e13805 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta5-SNAPSHOT + 2.0-beta5 ../ org.apache.logging.log4j From 80803d212be01fca27a08c87afe22c19546aa857 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 20 Apr 2013 21:20:31 +0000 Subject: [PATCH 017/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1470233 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 4e13805..f7c83ef 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta5 + 2.0-beta6-SNAPSHOT ../ org.apache.logging.log4j From dc5312092d41c7d8bd553418ec6364ed3cb15a6b Mon Sep 17 00:00:00 2001 From: rpopma Date: Fri, 26 Apr 2013 16:55:35 +0000 Subject: [PATCH 018/363] LOG4J2-215 various doc fixes git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1476289 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/src/site/xdoc/index.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/log4j-to-slf4j/src/site/xdoc/index.xml b/log4j-to-slf4j/src/site/xdoc/index.xml index 8462ab0..90697f6 100644 --- a/log4j-to-slf4j/src/site/xdoc/index.xml +++ b/log4j-to-slf4j/src/site/xdoc/index.xml @@ -36,9 +36,7 @@

- The Log4j 2 to SLF4J adapter requires at least Java 5. Use of this adapter together with the - SLF4J bridge should never be attempted as it will cause a events to endlessly be routed between - SLF4J and Log4j 2. + The Log4j 2 to SLF4J adapter requires at least Java 6.

@@ -47,6 +45,12 @@ Include this jar, the SLF4J jar(s) and an SLF4J logging implementation jar together. Configure the logging implementation as required.

+

+ Use of the SLF4J adapter (log4j-to-slf4j-2.0.jar) together with + the SLF4J bridge (log4j-slf4j-impl-2.0.jar) should + never be attempted as it will cause events to endlessly be routed between + SLF4J and Log4j 2. +

From de1702298c8cdfed1069d7a1b78b701188e409b8 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 28 Apr 2013 01:27:27 +0000 Subject: [PATCH 019/363] LOG4J2-221 - Remove hundreds of compiler warnings git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1476703 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 3 +-- .../java/org/apache/logging/slf4j/MDCContextMap.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f7c83ef..a528e41 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -23,7 +23,6 @@ 2.0-beta6-SNAPSHOT ../ - org.apache.logging.log4j log4j-to-slf4j jar Apache Log4j to SLF4J Adapter @@ -167,7 +166,7 @@ maven-pmd-plugin ${pmd.plugin.version} - 1.5 + ${maven.compile.target} 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 index 5eabba4..da0720c 100644 --- 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 @@ -25,34 +25,44 @@ * Bind the ThreadContextMap to the SLF4J MDC. */ public class MDCContextMap implements ThreadContextMap { + @Override public void put(final String key, final String value) { MDC.put(key, value); } + @Override public String get(final String key) { return MDC.get(key); } + @Override public void remove(final String key) { MDC.remove(key); } + @Override public void clear() { MDC.clear(); } + @Override public boolean containsKey(final String key) { return MDC.getCopyOfContextMap().containsKey(key); } + @Override + @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API public Map getContext() { return MDC.getCopyOfContextMap(); } + @Override + @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API public Map get() { return MDC.getCopyOfContextMap(); } + @Override public boolean isEmpty() { return MDC.getCopyOfContextMap().isEmpty(); } From 24c843fbfdb0eb90df2fdaaca031672405f28f48 Mon Sep 17 00:00:00 2001 From: rpopma Date: Wed, 1 May 2013 15:21:20 +0000 Subject: [PATCH 020/363] LOG4J2-230, LOG4J2-204 (added check in constructor to improve error reporting when misconfigured) git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1478048 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLoggerContext.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 index 6f98ec0..d4031eb 100644 --- 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 @@ -30,6 +30,17 @@ public class SLF4JLoggerContext implements LoggerContext { private final ConcurrentMap loggers = new ConcurrentHashMap(); + public SLF4JLoggerContext() { + // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) + try { + Class.forName("org.slf4j.helpers.Log4JLoggerFactory"); + 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)"); + } catch (Throwable classNotFoundIsGood) { + // org.slf4j.helpers.Log4JLoggerFactory is not on classpath. Good! + } + } + public Object getExternalContext() { return null; } From f3d925b0bf3e7d6657be8aa897304fdf453c0286 Mon Sep 17 00:00:00 2001 From: rpopma Date: Wed, 1 May 2013 16:22:05 +0000 Subject: [PATCH 021/363] fix for LOG4J2-230, moved check to SLF4JLoggerContextFactory, credited original reporter of issue 204 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1478075 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/logging/slf4j/SLF4JLoggerContext.java | 11 ----------- .../logging/slf4j/SLF4JLoggerContextFactory.java | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-) 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 index d4031eb..6f98ec0 100644 --- 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 @@ -30,17 +30,6 @@ public class SLF4JLoggerContext implements LoggerContext { private final ConcurrentMap loggers = new ConcurrentHashMap(); - public SLF4JLoggerContext() { - // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) - try { - Class.forName("org.slf4j.helpers.Log4JLoggerFactory"); - 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)"); - } catch (Throwable classNotFoundIsGood) { - // org.slf4j.helpers.Log4JLoggerFactory is not on classpath. Good! - } - } - public Object getExternalContext() { return null; } 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 index ddf6ef9..2b490c4 100644 --- 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 @@ -27,6 +27,21 @@ public class SLF4JLoggerContextFactory implements LoggerContextFactory { private static LoggerContext context = new SLF4JLoggerContext(); + public SLF4JLoggerContextFactory() { + // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) + boolean misconfigured = false; + try { + Class.forName("org.slf4j.helpers.Log4JLoggerFactory"); + misconfigured = true; + } catch (Throwable classNotFoundIsGood) { + // 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)"); + } + } + public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) { return context; } From 57d519edfdaab500812a26e245dcf326dcea4966 Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 2 May 2013 13:29:53 +0000 Subject: [PATCH 022/363] LOG4J2-230 solution improvement: catch only ClassNotFoundEx, allow other errors to propagate git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1478367 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 2b490c4..00b3161 100644 --- 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 @@ -33,7 +33,7 @@ public SLF4JLoggerContextFactory() { try { Class.forName("org.slf4j.helpers.Log4JLoggerFactory"); misconfigured = true; - } catch (Throwable classNotFoundIsGood) { + } catch (ClassNotFoundException classNotFoundIsGood) { // org.slf4j.helpers.Log4JLoggerFactory is not on classpath. Good! } if (misconfigured) { From f93256d542fd5ed4c00b16d1df0399abcbce9a02 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 May 2013 00:38:53 +0000 Subject: [PATCH 023/363] Upgrade findbugs version to fix OutOfMemoryError in mvn site git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479423 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index a528e41..7d10233 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -135,11 +135,13 @@ org.codehaus.mojo findbugs-maven-plugin - 2.3.2 + 2.5.2 + true + -Duser.language=en Normal Default - findbugs-exclude-filter.xml + ${log4jParentDir}/findbugs-exclude-filter.xml From 9d3f067d8f380991439f7950660c2ddfb8a89f1a Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 May 2013 01:09:12 +0000 Subject: [PATCH 024/363] [maven-release-plugin] prepare release log4j-2.0-beta6 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479436 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7d10233..14a4195 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta6-SNAPSHOT + 2.0-beta6 ../ log4j-to-slf4j From 912ec6f9035b6f4f4cc02077d833d1b0c66ac7a2 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 May 2013 01:09:41 +0000 Subject: [PATCH 025/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479438 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 14a4195..3e06c09 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta6 + 2.0-beta7-SNAPSHOT ../ log4j-to-slf4j From bb76c121ee21b5e78cea8977828d204825549acf Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 May 2013 01:37:35 +0000 Subject: [PATCH 026/363] Revert release to 2.0-beta6-SNAPSHOT git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479444 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3e06c09..7d10233 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7-SNAPSHOT + 2.0-beta6-SNAPSHOT ../ log4j-to-slf4j From c508c448e0fb89c952ce00b2a6c1203aa6d4a867 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 May 2013 01:55:20 +0000 Subject: [PATCH 027/363] [maven-release-plugin] prepare release log4j-2.0-beta6 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479449 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7d10233..14a4195 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta6-SNAPSHOT + 2.0-beta6 ../ log4j-to-slf4j From acc8e7fe885ea6629839b7657518a744c2e68077 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 May 2013 01:55:32 +0000 Subject: [PATCH 028/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479451 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 14a4195..3e06c09 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta6 + 2.0-beta7-SNAPSHOT ../ log4j-to-slf4j From 8371f0290e357625ca301a030b54c28ed6ceb92b Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 May 2013 18:22:39 +0000 Subject: [PATCH 029/363] Revert version numbers for respin git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479664 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3e06c09..7d10233 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7-SNAPSHOT + 2.0-beta6-SNAPSHOT ../ log4j-to-slf4j From c7431598ea27c6af7b95e43ffe4c8cffc90e69b0 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 7 May 2013 01:57:42 +0000 Subject: [PATCH 030/363] [maven-release-plugin] prepare release log4j-2.0-beta6 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479747 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7d10233..14a4195 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta6-SNAPSHOT + 2.0-beta6 ../ log4j-to-slf4j From daf8f7a306a299fbb357515cb6301dc0b04a8e53 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 7 May 2013 01:57:58 +0000 Subject: [PATCH 031/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1479749 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 14a4195..3e06c09 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta6 + 2.0-beta7-SNAPSHOT ../ log4j-to-slf4j From a7bfe0480b8a7b9554fc80dfb7a6e8b450825e0e Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 9 May 2013 15:35:35 +0000 Subject: [PATCH 032/363] Add missing @Override (Java 6). git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1480696 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 4 ++++ .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 2 ++ 2 files changed, 6 insertions(+) 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 index 6f98ec0..5d782b2 100644 --- 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 @@ -30,10 +30,12 @@ public class SLF4JLoggerContext implements LoggerContext { private final ConcurrentMap loggers = new ConcurrentHashMap(); + @Override public Object getExternalContext() { return null; } + @Override public Logger getLogger(final String name) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, LoggerFactory.getLogger(name))); @@ -41,6 +43,7 @@ public Logger getLogger(final String name) { return loggers.get(name); } + @Override public Logger getLogger(final String name, final MessageFactory messageFactory) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); @@ -48,6 +51,7 @@ public Logger getLogger(final String name, final MessageFactory messageFactory) return loggers.get(name); } + @Override public boolean hasLogger(final String name) { return loggers.containsKey(name); } 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 index 00b3161..5e071c6 100644 --- 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 @@ -42,10 +42,12 @@ public SLF4JLoggerContextFactory() { } } + @Override public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) { return context; } + @Override public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext, URI configLocation) { return context; From fd71dc79ebb5c13696cb6da1db2d3be2ec8e5d79 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sat, 11 May 2013 22:27:41 +0000 Subject: [PATCH 033/363] Whitespace police on Maven POM files git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1481440 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 240 ++++++++++++++++++++--------------------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3e06c09..3ad5010 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -1,3 +1,4 @@ + 4.0.0 @@ -63,126 +63,126 @@ test - - - - org.apache.maven.plugins - maven-changes-plugin - ${changes.plugin.version} - - - - changes-report - - - - - %URL%/show_bug.cgi?id=%ISSUE% - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.7 - - - ${log4jParentDir}/checkstyle.xml - ${log4jParentDir}/checkstyle-suppressions.xml - false - basedir=${basedir} - licensedir=${log4jParentDir}/checkstyle-header.txt - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${javadoc.plugin.version} - - Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.
+ + + + org.apache.maven.plugins + maven-changes-plugin + ${changes.plugin.version} + + + + changes-report + + + + + %URL%/show_bug.cgi?id=%ISSUE% + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.7 + + + ${log4jParentDir}/checkstyle.xml + ${log4jParentDir}/checkstyle-suppressions.xml + false + basedir=${basedir} + licensedir=${log4jParentDir}/checkstyle-header.txt + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${javadoc.plugin.version} + + Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.

]]>
- - false - true - - - issue - a - JIRA issue: - - - doubt - a - Troublesome: - - - compare - a - Compare with: - - -
- - - non-aggregate - - javadoc - - - -
- - org.codehaus.mojo - findbugs-maven-plugin - 2.5.2 - - true - -Duser.language=en - Normal - Default - ${log4jParentDir}/findbugs-exclude-filter.xml - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.3 - - - non-aggregate - - jxr - - - - aggregate - - aggregate - - - - - - org.apache.maven.plugins - maven-pmd-plugin - ${pmd.plugin.version} - - ${maven.compile.target} - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.2 - - - - - - - -
-
+ + false + true + + + issue + a + JIRA issue: + + + doubt + a + Troublesome: + + + compare + a + Compare with: + + +
+ + + non-aggregate + + javadoc + + + +
+ + org.codehaus.mojo + findbugs-maven-plugin + 2.5.2 + + true + -Duser.language=en + Normal + Default + ${log4jParentDir}/findbugs-exclude-filter.xml + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + + non-aggregate + + jxr + + + + aggregate + + aggregate + + + + + + org.apache.maven.plugins + maven-pmd-plugin + ${pmd.plugin.version} + + ${maven.compile.target} + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.2 + + + + + + + +
+
From 90cbfac9dcf5b68eeb203ac92de222390c40e1ae Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Thu, 16 May 2013 21:03:20 +0000 Subject: [PATCH 034/363] - Using Log4j instead of Log4J Part 1: Log4j is used hundreds of times, but Log4J (capital J) is used about 100 times. Replacing all Log4J with Log4j for consistency. - Replacing all Log4j2 with Log4j 2 for consistency. - Fixing numerous spelling errors in documentation. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1483567 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/src/site/site.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/log4j-to-slf4j/src/site/site.xml b/log4j-to-slf4j/src/site/site.xml index 62632f3..08ca886 100644 --- a/log4j-to-slf4j/src/site/site.xml +++ b/log4j-to-slf4j/src/site/site.xml @@ -27,7 +27,7 @@ - + @@ -39,7 +39,7 @@ - + From 2df26c735cc6bb3f2b5fed3cf2200c25713a4a06 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Thu, 16 May 2013 21:18:28 +0000 Subject: [PATCH 035/363] Using Log4j instead of Log4J Part 2: Most classes that have Log4j in their name use lowercase J, but some use uppercase J. Replacing all Log4J with Log4j for consistency. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1483569 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/logging/slf4j/SLF4JLoggerContextFactory.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 index 5e071c6..543bd5c 100644 --- 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 @@ -16,11 +16,11 @@ */ package org.apache.logging.slf4j; +import java.net.URI; + import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.LoggerContextFactory; -import java.net.URI; - /** * */ @@ -31,10 +31,10 @@ public SLF4JLoggerContextFactory() { // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) boolean misconfigured = false; try { - Class.forName("org.slf4j.helpers.Log4JLoggerFactory"); + Class.forName("org.slf4j.helpers.Log4jLoggerFactory"); misconfigured = true; } catch (ClassNotFoundException classNotFoundIsGood) { - // org.slf4j.helpers.Log4JLoggerFactory is not on classpath. Good! + // 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 " From 603f7e6a73365c25f26258868731d35c058f2114 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 19 May 2013 22:29:14 +0000 Subject: [PATCH 036/363] LOG4J2-223 - Remove LoggerContext when LoggerContext is stopped git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1484363 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 4 ++++ 1 file changed, 4 insertions(+) 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 index 543bd5c..818d409 100644 --- 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 @@ -52,4 +52,8 @@ public LoggerContext getContext(final String fqcn, final ClassLoader loader, fin URI configLocation) { return context; } + + @Override + public void removeContext(LoggerContext context) { + } } From 96d45f573a48fd0d160d0e2f8f8525b7adfe26b6 Mon Sep 17 00:00:00 2001 From: rpopma Date: Sun, 26 May 2013 22:11:29 +0000 Subject: [PATCH 037/363] LOG4J2-154 improve ThreadContext performance with copy-on-write map and stack git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1486482 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index da0720c..b85dede 100644 --- 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 @@ -52,13 +52,13 @@ public boolean containsKey(final String key) { @Override @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API - public Map getContext() { + public Map getCopy() { return MDC.getCopyOfContextMap(); } @Override @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API - public Map get() { + public Map getImmutableMapOrNull() { return MDC.getCopyOfContextMap(); } From 45fbe0ca15af035e5a6d22645fffb8af1272195c Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Tue, 28 May 2013 22:18:32 +0000 Subject: [PATCH 038/363] Refactor Cobertura plugin version into a property in the main POM. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1487151 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3ad5010..c1058f5 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -174,7 +174,7 @@ org.codehaus.mojo cobertura-maven-plugin - 2.2 + ${cobertura.plugin.version} From 92b5630165839f81271f5071d2d13dc0b2050122 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Wed, 29 May 2013 01:14:18 +0000 Subject: [PATCH 039/363] Enable code coverage. A comment in the POMs used to say this was broken with the 2.2 Cobertura plugin, but it works just fine with 2.5.2. To consider: Should we do like Apache Commons and provide a toggle to run JaCoCo too? git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1487179 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c1058f5..8a662c7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -175,12 +175,6 @@ org.codehaus.mojo cobertura-maven-plugin ${cobertura.plugin.version} - - - - - - From 7b623069009beb04e8504558d6795a416fdafcb6 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 05:35:27 +0000 Subject: [PATCH 040/363] [maven-release-plugin] prepare release log4j-2.0-beta7 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488466 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 8a662c7..f266bd7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7-SNAPSHOT + 2.0-beta7 ../ log4j-to-slf4j From a2a614987e827f03c11b38003f5d0b303da838f8 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 05:35:38 +0000 Subject: [PATCH 041/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488468 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f266bd7..0dccd35 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7 + 2.0-beta8-SNAPSHOT ../ log4j-to-slf4j From d210a9c24de72a362ce338ba83fe96009b0d18c7 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 15:38:58 +0000 Subject: [PATCH 042/363] revert version to re-release git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488539 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0dccd35..8a662c7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8-SNAPSHOT + 2.0-beta7-SNAPSHOT ../ log4j-to-slf4j From 074b8053b46f414fc1de2a79e680ebb97aca6857 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 20:36:55 +0000 Subject: [PATCH 043/363] [maven-release-plugin] prepare release log4j-2.0-beta7 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488591 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 8a662c7..f266bd7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7-SNAPSHOT + 2.0-beta7 ../ log4j-to-slf4j From 73393f98d809ebe7b88746da61c38ffa5e58ede0 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 20:37:08 +0000 Subject: [PATCH 044/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488593 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f266bd7..0dccd35 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7 + 2.0-beta8-SNAPSHOT ../ log4j-to-slf4j From 7dc11c1932a040ad0faa78fd246144d64477819e Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 21:28:52 +0000 Subject: [PATCH 045/363] revert release git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488608 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0dccd35..8a662c7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8-SNAPSHOT + 2.0-beta7-SNAPSHOT ../ log4j-to-slf4j From 0d5cc07654171fd2bd5e439fb9072c8f94475579 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 21:38:04 +0000 Subject: [PATCH 046/363] [maven-release-plugin] prepare release log4j-2.0-beta7 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488610 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 8a662c7..f266bd7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7-SNAPSHOT + 2.0-beta7 ../ log4j-to-slf4j From 211de44fd5f943aa849beac221266cb180c1e13f Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 1 Jun 2013 21:38:15 +0000 Subject: [PATCH 047/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488612 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f266bd7..0dccd35 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7 + 2.0-beta8-SNAPSHOT ../ log4j-to-slf4j From ab2129a3b6c0e9cae30a0098d78cd13efc3ccac9 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 2 Jun 2013 13:02:21 +0000 Subject: [PATCH 048/363] Revert version number for respin git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488699 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0dccd35..8a662c7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8-SNAPSHOT + 2.0-beta7-SNAPSHOT ../ log4j-to-slf4j From 14376d48a2c0f154e71b5602557c9236e250541c Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 2 Jun 2013 13:10:06 +0000 Subject: [PATCH 049/363] [maven-release-plugin] prepare release log4j-2.0-beta7 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488704 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 8a662c7..f266bd7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7-SNAPSHOT + 2.0-beta7 ../ log4j-to-slf4j From ceb52a60b555be7c852b4e999f2888b8a22607e8 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 2 Jun 2013 13:11:29 +0000 Subject: [PATCH 050/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1488706 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f266bd7..0dccd35 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7 + 2.0-beta8-SNAPSHOT ../ log4j-to-slf4j From 531ad01e733c68bdec8455dde1bcf247bffb05c9 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 4 Jun 2013 16:04:11 +0000 Subject: [PATCH 051/363] Revert version number. Disable Cobertura git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1489493 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0dccd35..3efddd6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8-SNAPSHOT + 2.0-beta7-SNAPSHOT ../ log4j-to-slf4j @@ -175,6 +175,12 @@ org.codehaus.mojo cobertura-maven-plugin ${cobertura.plugin.version} + + + + + + From 3649a0b348cacaf7ff068c556fec5bc5485f608d Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 4 Jun 2013 16:11:34 +0000 Subject: [PATCH 052/363] [maven-release-plugin] prepare release log4j-2.0-beta7 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1489494 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3efddd6..2baaa91 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7-SNAPSHOT + 2.0-beta7 ../ log4j-to-slf4j From 8405c526f6b8367321813556b8b84e24089c9835 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 4 Jun 2013 16:11:57 +0000 Subject: [PATCH 053/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1489497 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 2baaa91..e0d22f1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta7 + 2.0-beta8-SNAPSHOT ../ log4j-to-slf4j From 949946823cd756ff8d7abff4b50e9a10330952cd Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 7 Jul 2013 19:26:13 +0000 Subject: [PATCH 054/363] Per discussions on mailing list, increasing visibility of AbstractLogger#log(Marker, String, Level, Message, Throwable) so that anyone can call it. This will enable https://issues.jboss.org/browse/JBLOGGING-95 to be easily accomplished. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1500514 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index e516651..72cbc80 100644 --- 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 @@ -46,7 +46,7 @@ public SLF4JLogger(final String name, final MessageFactory messageFactory, final } @Override - protected void log(final Marker marker, final String fqcn, final Level level, final Message data, + public void log(final Marker marker, final String fqcn, final Level level, final Message data, final Throwable t) { if (locationAwareLogger != null) { if (data instanceof LoggerNameAwareMessage) { From 171d70756a8fdacda733cf1d74cb361c760f2e04 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 7 Jul 2013 21:02:20 +0000 Subject: [PATCH 055/363] Checkstyle police git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1500537 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/logging/slf4j/MDCContextMap.java | 4 ++-- .../java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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 index b85dede..2636b74 100644 --- 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 @@ -16,11 +16,11 @@ */ package org.apache.logging.slf4j; +import java.util.Map; + import org.apache.logging.log4j.spi.ThreadContextMap; import org.slf4j.MDC; -import java.util.Map; - /** * Bind the ThreadContextMap to the SLF4J MDC. */ 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 index 5d782b2..6d76081 100644 --- 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 @@ -16,14 +16,14 @@ */ package org.apache.logging.slf4j; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.MessageFactory; import org.apache.logging.log4j.spi.LoggerContext; import org.slf4j.LoggerFactory; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - /** * */ From 6c6fca367f9dd69d36f9bc9c85957a076125eb8a Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Tue, 9 Jul 2013 06:08:25 +0000 Subject: [PATCH 056/363] Add final modifier to private fields. Add final modifier to method parameters. Add final modifier to local variables. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1501104 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 index 818d409..4ac0767 100644 --- 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 @@ -33,7 +33,7 @@ public SLF4JLoggerContextFactory() { try { Class.forName("org.slf4j.helpers.Log4jLoggerFactory"); misconfigured = true; - } catch (ClassNotFoundException classNotFoundIsGood) { + } catch (final ClassNotFoundException classNotFoundIsGood) { // org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good! } if (misconfigured) { @@ -49,11 +49,11 @@ public LoggerContext getContext(final String fqcn, final ClassLoader loader, fin @Override public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext, - URI configLocation) { + final URI configLocation) { return context; } @Override - public void removeContext(LoggerContext context) { + public void removeContext(final LoggerContext context) { } } From 6f87dc58b27f79a5ae6fe23ce0b0837bd19a9cc0 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 16:27:03 +0000 Subject: [PATCH 057/363] [maven-release-plugin] prepare release log4j-2.0-beta8 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1501830 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e0d22f1..0d7bd84 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8-SNAPSHOT + 2.0-beta8 ../ log4j-to-slf4j From 56a656eb5f3559b482c5e8c06bf7dad9717409bc Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 16:27:10 +0000 Subject: [PATCH 058/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1501832 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0d7bd84..eeea53b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8 + 2.0-beta9-SNAPSHOT ../ log4j-to-slf4j From 74679a50c6eb50d33ffc6567fdbd3f50b6829f9f Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 17:55:25 +0000 Subject: [PATCH 059/363] Revert release version git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1501882 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index eeea53b..e0d22f1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta9-SNAPSHOT + 2.0-beta8-SNAPSHOT ../ log4j-to-slf4j From 7df4cc13a2afc64c53493e80681805810d947214 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 18:17:39 +0000 Subject: [PATCH 060/363] [maven-release-plugin] prepare release log4j-2.0-beta8 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1501892 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e0d22f1..0d7bd84 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8-SNAPSHOT + 2.0-beta8 ../ log4j-to-slf4j From c6095efac41273f53128f7a21b2c5c82057ad314 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 18:17:46 +0000 Subject: [PATCH 061/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1501894 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0d7bd84..eeea53b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8 + 2.0-beta9-SNAPSHOT ../ log4j-to-slf4j From bc27fde087f8e273b53aaf644e77cbf76f04ec17 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 20:54:25 +0000 Subject: [PATCH 062/363] Revert release version git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1501988 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index eeea53b..e0d22f1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta9-SNAPSHOT + 2.0-beta8-SNAPSHOT ../ log4j-to-slf4j From 0a59d4472660bf1be5397f88a7c0e03c1fa4e28f Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 21:14:06 +0000 Subject: [PATCH 063/363] [maven-release-plugin] prepare release log4j-2.0-beta8 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1502001 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e0d22f1..0d7bd84 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8-SNAPSHOT + 2.0-beta8 ../ log4j-to-slf4j From 223f715ccd4ca570cc431c872ca3daf0ab35c883 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 10 Jul 2013 21:14:10 +0000 Subject: [PATCH 064/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1502003 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0d7bd84..eeea53b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta8 + 2.0-beta9-SNAPSHOT ../ log4j-to-slf4j From 5fa5eefe3d965d0a1dd7aaee89b2d0ff466037fd Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Sat, 13 Jul 2013 05:16:14 +0000 Subject: [PATCH 065/363] [LOG4J2-305] Ease porting from 1.x Logger.getRootLogger(): add LogManager.getRootLogger(). git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1502746 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 873c986..ac6881b 100644 --- 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 @@ -60,7 +60,7 @@ public static void setupClass() throws Exception { configure(CONFIG); logger = LogManager.getLogger(LoggerTest.class); assertTrue("Incorrect SLF4J Logger", ((SLF4JLogger) logger).getLogger() == slf4jLogger); - root = LogManager.getLogger(""); + root = LogManager.getRootLogger(); rootLogger = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); list = (StringListAppender) rootLogger.getAppender("LIST"); rootLogger.detachAppender("console"); From 4ec0f4d06ac8c4efd033e317b5f04fc491e41170 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 13 Aug 2013 02:40:11 +0000 Subject: [PATCH 066/363] LOG4J2-309 - Insure jars and distributions only have a single License and Notice file. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1513327 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index eeea53b..f9e26f8 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -63,6 +63,25 @@ test + + + + + org.apache.maven.plugins + maven-remote-resources-plugin + + + + process + + + false + + + + + + From cf3bb771d1778bd995ce4e4179109fd9f95744a0 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Wed, 14 Aug 2013 20:05:54 +0000 Subject: [PATCH 067/363] [LOG4J2-353] Use consistent conventions in configuration files: "appender-ref" -> "AppenderRef". git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1514021 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/logging/slf4j/LoggerTest.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 index ac6881b..f615310 100644 --- 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 @@ -24,22 +24,23 @@ import java.util.Date; import java.util.List; -import ch.qos.logback.classic.joran.JoranConfigurator; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.joran.spi.JoranException; 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 ch.qos.logback.core.testUtil.StringListAppender; -import ch.qos.logback.classic.LoggerContext; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.slf4j.LoggerFactory; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.testUtil.StringListAppender; + /** * */ @@ -74,6 +75,8 @@ private static void configure(final String file) throws JoranException { @Before public void before() { + assertNotNull(list); + assertNotNull(list.strList); list.strList.clear(); } From 6d75f3c54d02b8bbfc2a04b3750413337ac8e7de Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 14 Sep 2013 14:16:06 +0000 Subject: [PATCH 068/363] [maven-release-plugin] prepare release log4j-2.0-beta9 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1523249 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f9e26f8..6bfa267 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta9-SNAPSHOT + 2.0-beta9 ../ log4j-to-slf4j From a426499506d175e86f1f998e2cdb677052d26617 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 14 Sep 2013 14:16:11 +0000 Subject: [PATCH 069/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1523251 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6bfa267..aead49f 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-beta9 + 2.0RC1-SNAPSHOT ../ log4j-to-slf4j From 717d9d2e90e6bef8bfd104e23c85834324be63c2 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 5 Dec 2013 14:43:40 +0000 Subject: [PATCH 070/363] Start work on making The AbstractLogger implement Serializable. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1548155 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 72cbc80..924c9f9 100644 --- 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 @@ -30,7 +30,8 @@ */ public class SLF4JLogger extends AbstractLogger { - private final org.slf4j.Logger logger; + private static final long serialVersionUID = 1L; + private final org.slf4j.Logger logger; private final LocationAwareLogger locationAwareLogger; public SLF4JLogger(final String name, final org.slf4j.Logger logger) { From cbe50af8fdcb1a7f778e31124a66a29f848aaa1c Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 4 Jan 2014 18:25:20 +0000 Subject: [PATCH 071/363] LOG4J2-459 - Set external context when constructing the LoggerContext git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1555400 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/logging/slf4j/SLF4JLoggerContextFactory.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 index 4ac0767..95e12b1 100644 --- 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 @@ -43,13 +43,14 @@ public SLF4JLoggerContextFactory() { } @Override - public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) { + 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 boolean currentContext, - final URI configLocation) { + public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext, + final boolean currentContext, final URI configLocation) { return context; } From 0ec7dabd8fd8a8ca0c8a7d37d182a96e80370ffd Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 12 Jan 2014 19:44:54 +0000 Subject: [PATCH 072/363] Configuration was being processed twice at startup. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1557603 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 95e12b1..cd84cdc 100644 --- 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 @@ -50,7 +50,7 @@ public LoggerContext getContext(final String fqcn, final ClassLoader loader, fin @Override public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext, - final boolean currentContext, final URI configLocation) { + final boolean currentContext, final URI configLocation, final String name) { return context; } From 0432b5b77780c5a566eadcccd51a2dad3ada574c Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 23 Jan 2014 07:25:07 +0000 Subject: [PATCH 073/363] [LOG4J2-508] Add new Levels: NOTICE, DIAG, VERBOSE. Fill in methods. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1560602 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLogger.java | 94 ++++++++++--------- 1 file changed, 51 insertions(+), 43 deletions(-) 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 index 924c9f9..c527842 100644 --- 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 @@ -57,24 +57,27 @@ public void log(final Marker marker, final String fqcn, final Level level, final data.getParameters(), t); } else { switch (level) { - case DEBUG : - logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case TRACE : - logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case INFO : - logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case WARN : - logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case ERROR : - logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - default : - logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; + case TRACE: + logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case VERBOSE: + case DEBUG: + case DIAG: + logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case INFO: + case NOTICE: + logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case WARN: + logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case ERROR: + logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + default: + logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; } } } @@ -94,18 +97,21 @@ private org.slf4j.Marker getMarker(final Marker marker) { private int convertLevel(final Level level) { switch (level) { - 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; + case TRACE: + return LocationAwareLogger.TRACE_INT; + case VERBOSE: + case DEBUG: + case DIAG: + return LocationAwareLogger.DEBUG_INT; + case INFO: + case NOTICE: + return LocationAwareLogger.INFO_INT; + case WARN: + return LocationAwareLogger.WARN_INT; + case ERROR: + return LocationAwareLogger.ERROR_INT; + default: + return LocationAwareLogger.ERROR_INT; } } @@ -137,19 +143,21 @@ protected boolean isEnabled(final Level level, final Marker marker, final Messag private boolean isEnabledFor(final Level level, final Marker marker) { final org.slf4j.Marker slf4jMarker = getMarker(marker); switch (level) { - 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); - + case TRACE: + return logger.isTraceEnabled(slf4jMarker); + case VERBOSE: + case DEBUG: + case DIAG: + return logger.isDebugEnabled(slf4jMarker); + case INFO: + case NOTICE: + return logger.isInfoEnabled(slf4jMarker); + case WARN: + return logger.isWarnEnabled(slf4jMarker); + case ERROR: + return logger.isErrorEnabled(slf4jMarker); + default: + return logger.isErrorEnabled(slf4jMarker); } } From 3addddc4ed3715e077fc12c5ee73b08cf2edfa0a Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Fri, 24 Jan 2014 17:49:38 +0000 Subject: [PATCH 074/363] [LOG4J2-508] Add new Levels: NOTICE, DIAG, VERBOSE. VETO by Remko Popma. Reverse-merging r1560602 through r1560601. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1561090 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLogger.java | 94 +++++++++---------- 1 file changed, 43 insertions(+), 51 deletions(-) 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 index c527842..924c9f9 100644 --- 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 @@ -57,27 +57,24 @@ public void log(final Marker marker, final String fqcn, final Level level, final data.getParameters(), t); } else { switch (level) { - case TRACE: - logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case VERBOSE: - case DEBUG: - case DIAG: - logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case INFO: - case NOTICE: - logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case WARN: - logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - case ERROR: - logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; - default: - logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); - break; + case DEBUG : + logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case TRACE : + logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case INFO : + logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case WARN : + logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + case ERROR : + logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; + default : + logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + break; } } } @@ -97,21 +94,18 @@ private org.slf4j.Marker getMarker(final Marker marker) { private int convertLevel(final Level level) { switch (level) { - case TRACE: - return LocationAwareLogger.TRACE_INT; - case VERBOSE: - case DEBUG: - case DIAG: - return LocationAwareLogger.DEBUG_INT; - case INFO: - case NOTICE: - return LocationAwareLogger.INFO_INT; - case WARN: - return LocationAwareLogger.WARN_INT; - case ERROR: - return LocationAwareLogger.ERROR_INT; - default: - return LocationAwareLogger.ERROR_INT; + 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; } } @@ -143,21 +137,19 @@ protected boolean isEnabled(final Level level, final Marker marker, final Messag private boolean isEnabledFor(final Level level, final Marker marker) { final org.slf4j.Marker slf4jMarker = getMarker(marker); switch (level) { - case TRACE: - return logger.isTraceEnabled(slf4jMarker); - case VERBOSE: - case DEBUG: - case DIAG: - return logger.isDebugEnabled(slf4jMarker); - case INFO: - case NOTICE: - return logger.isInfoEnabled(slf4jMarker); - case WARN: - return logger.isWarnEnabled(slf4jMarker); - case ERROR: - return logger.isErrorEnabled(slf4jMarker); - default: - return logger.isErrorEnabled(slf4jMarker); + 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); + } } From 1a061333f3948b6a8599cf643c900ef32def1cbb Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 26 Jan 2014 19:34:49 +0000 Subject: [PATCH 075/363] LOG4J2-41 - Add support for custom logging levels git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1561537 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/logging/slf4j/SLF4JLogger.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 index 924c9f9..dff9725 100644 --- 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 @@ -18,6 +18,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.Level.StdLevel; import org.apache.logging.log4j.message.LoggerNameAwareMessage; import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.MessageFactory; @@ -56,7 +57,7 @@ public void log(final Marker marker, final String fqcn, final Level level, final locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), data.getFormattedMessage(), data.getParameters(), t); } else { - switch (level) { + switch (StdLevel.getStdLevel(level)) { case DEBUG : logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); break; @@ -93,7 +94,7 @@ private org.slf4j.Marker getMarker(final Marker marker) { } private int convertLevel(final Level level) { - switch (level) { + switch (StdLevel.getStdLevel(level)) { case DEBUG : return LocationAwareLogger.DEBUG_INT; case TRACE : @@ -136,7 +137,7 @@ protected boolean isEnabled(final Level level, final Marker marker, final Messag private boolean isEnabledFor(final Level level, final Marker marker) { final org.slf4j.Marker slf4jMarker = getMarker(marker); - switch (level) { + switch (StdLevel.getStdLevel(level)) { case DEBUG : return logger.isDebugEnabled(slf4jMarker); case TRACE : From 9480b0fa09fa2de15ed295bf4b6c8ec30953375b Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 26 Jan 2014 22:35:25 +0000 Subject: [PATCH 076/363] Changes to custom Level support based on feedback git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1561564 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/logging/slf4j/SLF4JLogger.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 index dff9725..f28a2e1 100644 --- 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 @@ -18,7 +18,6 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.Level.StdLevel; import org.apache.logging.log4j.message.LoggerNameAwareMessage; import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.MessageFactory; @@ -57,7 +56,7 @@ public void log(final Marker marker, final String fqcn, final Level level, final locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), data.getFormattedMessage(), data.getParameters(), t); } else { - switch (StdLevel.getStdLevel(level)) { + switch (level.getStandardLevel()) { case DEBUG : logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); break; @@ -94,7 +93,7 @@ private org.slf4j.Marker getMarker(final Marker marker) { } private int convertLevel(final Level level) { - switch (StdLevel.getStdLevel(level)) { + switch (level.getStandardLevel()) { case DEBUG : return LocationAwareLogger.DEBUG_INT; case TRACE : @@ -137,7 +136,7 @@ protected boolean isEnabled(final Level level, final Marker marker, final Messag private boolean isEnabledFor(final Level level, final Marker marker) { final org.slf4j.Marker slf4jMarker = getMarker(marker); - switch (StdLevel.getStdLevel(level)) { + switch (level.getStandardLevel()) { case DEBUG : return logger.isDebugEnabled(slf4jMarker); case TRACE : From 5b3de95a734ae900aeb746b9c63c82c734aa099b Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sat, 8 Feb 2014 03:29:47 +0000 Subject: [PATCH 077/363] Corrected version number to follow Maven version number syntax; without this change, it might not be ordered correctly in Maven version ordering once published. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1565902 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index aead49f..ad0a8ac 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0RC1-SNAPSHOT + 2.0-rc1-SNAPSHOT ../ log4j-to-slf4j From 73e7d220e532e28053f09806c95f5eca6fbab7c2 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sat, 8 Feb 2014 18:34:31 +0000 Subject: [PATCH 078/363] [maven-release-plugin] prepare release log4j-2.0-rc1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566085 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad0a8ac..5aa9393 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1-SNAPSHOT + 2.0-rc1 ../ log4j-to-slf4j From 1e8f2c1b61a459d0e668e3d39196a1aa78896362 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sat, 8 Feb 2014 18:34:39 +0000 Subject: [PATCH 079/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566087 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5aa9393..fb02fb9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1 + 2.0-rc2-SNAPSHOT ../ log4j-to-slf4j From a00be273f4e928ea5a0ab997f60d3cef4307a5c8 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sat, 8 Feb 2014 18:48:47 +0000 Subject: [PATCH 080/363] Reverting failed release git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566093 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fb02fb9..ad0a8ac 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2-SNAPSHOT + 2.0-rc1-SNAPSHOT ../ log4j-to-slf4j From 4c1544b68aecc32bc7b88f2264e52cd17b4792f2 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sat, 8 Feb 2014 19:26:44 +0000 Subject: [PATCH 081/363] [maven-release-plugin] prepare release log4j-2.0-rc1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566105 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad0a8ac..5aa9393 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1-SNAPSHOT + 2.0-rc1 ../ log4j-to-slf4j From 27bee305be5c346dadb77d12fda510a68665fa16 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sat, 8 Feb 2014 19:26:54 +0000 Subject: [PATCH 082/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566107 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5aa9393..fb02fb9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1 + 2.0-rc2-SNAPSHOT ../ log4j-to-slf4j From e6a595b45f5a4c8859c00c0104835c55904e26a6 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 05:01:42 +0000 Subject: [PATCH 083/363] Canceled vote for 2.0-rc1 RC1. Reverting version number changes. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566219 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fb02fb9..ad0a8ac 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2-SNAPSHOT + 2.0-rc1-SNAPSHOT ../ log4j-to-slf4j From 609fb3b3c2fbd27fb0e51c13b0dc86d2f664ea65 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 05:19:08 +0000 Subject: [PATCH 084/363] [maven-release-plugin] prepare release log4j-2.0-rc1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566224 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad0a8ac..5aa9393 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1-SNAPSHOT + 2.0-rc1 ../ log4j-to-slf4j From 36bc6ec9c80fcca8f5965702355789e926d38585 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 05:19:17 +0000 Subject: [PATCH 085/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566226 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5aa9393..fb02fb9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1 + 2.0-rc2-SNAPSHOT ../ log4j-to-slf4j From 46517fbaa541c415818d3a046e9df08ff48b1dc8 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 05:29:19 +0000 Subject: [PATCH 086/363] [maven-release-plugin] rollback the release of log4j-2.0-rc1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566228 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fb02fb9..ad0a8ac 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2-SNAPSHOT + 2.0-rc1-SNAPSHOT ../ log4j-to-slf4j From 4cd11089d89706ec3e03e5f0e95eacecceb08d89 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 05:39:09 +0000 Subject: [PATCH 087/363] [maven-release-plugin] prepare release log4j-2.0-rc1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566231 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad0a8ac..5aa9393 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1-SNAPSHOT + 2.0-rc1 ../ log4j-to-slf4j From cdafd956f22e8795cc265b8d6f18cff76071db0f Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 05:39:17 +0000 Subject: [PATCH 088/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566233 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5aa9393..fb02fb9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1 + 2.0-rc2-SNAPSHOT ../ log4j-to-slf4j From aace3c0c2fd5eb691f31f9a5c82059b9f7817216 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 06:32:03 +0000 Subject: [PATCH 089/363] Released failed due to error building site git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566239 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fb02fb9..ad0a8ac 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2-SNAPSHOT + 2.0-rc1-SNAPSHOT ../ log4j-to-slf4j From 981d15b25062f1ea604cbf43b636ced069adcf77 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 07:47:17 +0000 Subject: [PATCH 090/363] Resolving a bunch of Checkstyle, FindBugs, CPD, and PMD complaints in all modules except API and Core git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566249 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 2 +- .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 index f28a2e1..e63a57b 100644 --- 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 @@ -31,7 +31,7 @@ public class SLF4JLogger extends AbstractLogger { private static final long serialVersionUID = 1L; - private final org.slf4j.Logger logger; + private final org.slf4j.Logger logger; private final LocationAwareLogger locationAwareLogger; public SLF4JLogger(final String name, final org.slf4j.Logger logger) { 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 index cd84cdc..4cae70f 100644 --- 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 @@ -20,11 +20,13 @@ import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.LoggerContextFactory; +import org.apache.logging.log4j.status.StatusLogger; /** * */ public class SLF4JLoggerContextFactory implements LoggerContextFactory { + private static final StatusLogger LOGGER = StatusLogger.getLogger(); private static LoggerContext context = new SLF4JLoggerContext(); public SLF4JLoggerContextFactory() { @@ -34,7 +36,7 @@ public SLF4JLoggerContextFactory() { Class.forName("org.slf4j.helpers.Log4jLoggerFactory"); misconfigured = true; } catch (final ClassNotFoundException classNotFoundIsGood) { - // org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good! + 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 " From a8df5d061f74da1c8351e871fd01f2e954bc0313 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 19:03:20 +0000 Subject: [PATCH 091/363] [maven-release-plugin] prepare release log4j-2.0-rc1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566353 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad0a8ac..5aa9393 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1-SNAPSHOT + 2.0-rc1 ../ log4j-to-slf4j From 81c143b376845dfb0cc222aca6041de67425af99 Mon Sep 17 00:00:00 2001 From: nickwilliams Date: Sun, 9 Feb 2014 19:03:29 +0000 Subject: [PATCH 092/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1566355 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5aa9393..fb02fb9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc1 + 2.0-rc2-SNAPSHOT ../ log4j-to-slf4j From a3fdabc09110948dfb956f79e5a6b2c78ae4708f Mon Sep 17 00:00:00 2001 From: rpopma Date: Sun, 23 Mar 2014 04:50:14 +0000 Subject: [PATCH 093/363] LOG4J2-555: introduce LoggerProvider interface to facilitate implementing/extending Loggers git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1580445 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLogger.java | 35 +++++++++---------- .../logging/slf4j/SLF4JLoggerContext.java | 5 +-- 2 files changed, 20 insertions(+), 20 deletions(-) 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 index e63a57b..93af3c0 100644 --- 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 @@ -45,35 +45,34 @@ public SLF4JLogger(final String name, final MessageFactory messageFactory, final this.logger = logger; this.locationAwareLogger = logger instanceof LocationAwareLogger ? (LocationAwareLogger) logger : null; } - + @Override - public void log(final Marker marker, final String fqcn, final Level level, final Message data, - final Throwable t) { + public void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) { if (locationAwareLogger != null) { - if (data instanceof LoggerNameAwareMessage) { - ((LoggerNameAwareMessage) data).setLoggerName(getName()); + if (message instanceof LoggerNameAwareMessage) { + ((LoggerNameAwareMessage) message).setLoggerName(getName()); } - locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), data.getFormattedMessage(), - data.getParameters(), t); + locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), message.getFormattedMessage(), + message.getParameters(), t); } else { switch (level.getStandardLevel()) { case DEBUG : - logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + logger.debug(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case TRACE : - logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + logger.trace(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case INFO : - logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + logger.info(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case WARN : - logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + logger.warn(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case ERROR : - logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; default : - logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t); + logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; } } @@ -110,27 +109,27 @@ private int convertLevel(final Level level) { } @Override - protected boolean isEnabled(final Level level, final Marker marker, final String data) { + public boolean isEnabled(final Level level, final Marker marker, final String data) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) { + public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) { + public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) { + public boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) { return isEnabledFor(level, marker); } @Override - protected boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) { + public boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) { return isEnabledFor(level, marker); } 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 index 6d76081..8d778f0 100644 --- 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 @@ -22,6 +22,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.MessageFactory; import org.apache.logging.log4j.spi.LoggerContext; +import org.apache.logging.log4j.spi.LoggerProvider; import org.slf4j.LoggerFactory; /** @@ -36,7 +37,7 @@ public Object getExternalContext() { } @Override - public Logger getLogger(final String name) { + public LoggerProvider getLogger(final String name) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, LoggerFactory.getLogger(name))); } @@ -44,7 +45,7 @@ public Logger getLogger(final String name) { } @Override - public Logger getLogger(final String name, final MessageFactory messageFactory) { + public LoggerProvider getLogger(final String name, final MessageFactory messageFactory) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); } From b1c3c34e6d98bd2c4335b57d1b10305ab1ac72fd Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 24 Mar 2014 02:07:59 +0000 Subject: [PATCH 094/363] Sort methods. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1580699 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLogger.java | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) 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 index 93af3c0..60c5003 100644 --- 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 @@ -34,63 +34,18 @@ public class SLF4JLogger extends AbstractLogger { private final org.slf4j.Logger logger; private final LocationAwareLogger locationAwareLogger; - public SLF4JLogger(final String name, final org.slf4j.Logger logger) { - super(name); + 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 MessageFactory messageFactory, final org.slf4j.Logger logger) { - super(name, messageFactory); + public SLF4JLogger(final String name, final org.slf4j.Logger logger) { + super(name); this.logger = logger; this.locationAwareLogger = logger instanceof LocationAwareLogger ? (LocationAwareLogger) logger : null; } - @Override - public void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) { - if (locationAwareLogger != null) { - if (message instanceof LoggerNameAwareMessage) { - ((LoggerNameAwareMessage) message).setLoggerName(getName()); - } - locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), message.getFormattedMessage(), - message.getParameters(), t); - } else { - switch (level.getStandardLevel()) { - case DEBUG : - logger.debug(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); - break; - case TRACE : - logger.trace(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); - break; - case INFO : - logger.info(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); - break; - case WARN : - logger.warn(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); - break; - case ERROR : - logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); - break; - default : - logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); - break; - } - } - } - - private org.slf4j.Marker getMarker(final Marker marker) { - if (marker == null) { - return null; - } - final Marker parent = marker.getParent(); - final org.slf4j.Marker parentMarker = parent == null ? null : getMarker(parent); - final org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName()); - if (parentMarker != null && !slf4jMarker.contains(parentMarker)) { - slf4jMarker.add(parentMarker); - } - return slf4jMarker; - } - private int convertLevel(final Level level) { switch (level.getStandardLevel()) { case DEBUG : @@ -108,28 +63,45 @@ private int convertLevel(final Level level) { } } + public org.slf4j.Logger getLogger() { + return locationAwareLogger != null ? locationAwareLogger : logger; + } + + private org.slf4j.Marker getMarker(final Marker marker) { + if (marker == null) { + return null; + } + final Marker parent = marker.getParent(); + final org.slf4j.Marker parentMarker = parent == null ? null : getMarker(parent); + final org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName()); + if (parentMarker != null && !slf4jMarker.contains(parentMarker)) { + slf4jMarker.add(parentMarker); + } + return slf4jMarker; + } + @Override - public boolean isEnabled(final Level level, final Marker marker, final String data) { + 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 String data, final Throwable t) { + 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, final Object... p1) { + 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 Object data, final Throwable t) { + 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 Message data, final Throwable t) { + public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) { return isEnabledFor(level, marker); } @@ -152,8 +124,36 @@ private boolean isEnabledFor(final Level level, final Marker marker) { } } - public org.slf4j.Logger getLogger() { - return locationAwareLogger != null ? locationAwareLogger : logger; + @Override + public void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) { + if (locationAwareLogger != null) { + if (message instanceof LoggerNameAwareMessage) { + ((LoggerNameAwareMessage) message).setLoggerName(getName()); + } + locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), message.getFormattedMessage(), + message.getParameters(), t); + } else { + switch (level.getStandardLevel()) { + case DEBUG : + logger.debug(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + break; + case TRACE : + logger.trace(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + break; + case INFO : + logger.info(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + break; + case WARN : + logger.warn(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + break; + case ERROR : + logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + break; + default : + logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + break; + } + } } } From d7a83b20afdbaf6fec21f08b37d80803fd48c3d3 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 24 Mar 2014 05:30:20 +0000 Subject: [PATCH 095/363] Add org.apache.logging.log4j.Logger.getLevel(). git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1580752 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/logging/slf4j/SLF4JLogger.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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 index 60c5003..893e18d 100644 --- 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 @@ -22,6 +22,7 @@ import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.MessageFactory; import org.apache.logging.log4j.spi.AbstractLogger; +import org.slf4j.Logger; import org.slf4j.MarkerFactory; import org.slf4j.spi.LocationAwareLogger; @@ -63,6 +64,28 @@ private int convertLevel(final Level level) { } } + @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; } From b932d9d439b5b9bd29ddeef235da09db57c4da69 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 24 Mar 2014 05:32:48 +0000 Subject: [PATCH 096/363] Remove unused imports. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1580753 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 1 - .../main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 1 - 2 files changed, 2 deletions(-) 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 index 893e18d..baa4ec8 100644 --- 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 @@ -22,7 +22,6 @@ import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.MessageFactory; import org.apache.logging.log4j.spi.AbstractLogger; -import org.slf4j.Logger; import org.slf4j.MarkerFactory; import org.slf4j.spi.LocationAwareLogger; 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 index 8d778f0..125ccea 100644 --- 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 @@ -19,7 +19,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.MessageFactory; import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.LoggerProvider; From 0eb84a079ba4613a5eaa06a84ffc4721ce1d0ed3 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 24 Mar 2014 05:58:25 +0000 Subject: [PATCH 097/363] Rename AbstractLogger to AbstractLoggerProvider since it now implements LoggerProvider. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1580759 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index baa4ec8..36ca012 100644 --- 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 @@ -21,14 +21,14 @@ 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.spi.AbstractLoggerProvider; import org.slf4j.MarkerFactory; import org.slf4j.spi.LocationAwareLogger; /** * */ -public class SLF4JLogger extends AbstractLogger { +public class SLF4JLogger extends AbstractLoggerProvider { private static final long serialVersionUID = 1L; private final org.slf4j.Logger logger; From 26dd0eb7b816d6cea46bc27e62cbe16077b467a4 Mon Sep 17 00:00:00 2001 From: mattsicker Date: Sun, 20 Apr 2014 17:34:10 +0000 Subject: [PATCH 098/363] Clean up log4j-to-slf4j OSGi build. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1588798 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fb02fb9..b4728f9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -80,6 +80,15 @@ + + org.apache.felix + maven-bundle-plugin + + + org.apache.logging.slf4j + + + From 2a1f0c38003ce8ac320969b15b14cda52cdd0752 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Tue, 13 May 2014 21:18:08 +0000 Subject: [PATCH 099/363] Replace org.apache.logging.log4j.ThreadContext.clear() with the more precise clearMap(). - [LOG4J2-634] ThrowableProxy ctor throws an exception when using suppressed exceptions. - [LOG4J2-584] TCP and UDP socket servers should be able to handle JSON log events - [LOG4J2-583] TCP and UDP socket servers should be able to handle XML log events git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1594389 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index f615310..8b4497b 100644 --- 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 @@ -167,7 +167,7 @@ public void testImpliedThrowable() { public void mdc() { ThreadContext.put("TestYear", new Integer(2010).toString()); logger.debug("Debug message"); - ThreadContext.clear(); + ThreadContext.clearMap(); logger.debug("Debug message"); assertTrue("Incorrect number of events. Expected 2, actual " + list.strList.size(), list.strList.size() == 2); assertTrue("Incorrect year", list.strList.get(0).startsWith("2010")); From abc8a4026cf58be43dce3289ee35a7c4a7c95b1c Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Tue, 20 May 2014 12:28:29 +0000 Subject: [PATCH 100/363] Organize imports per the guidelines agreed upon on the ML. See https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk/src/ide/eclipse/4.3.2/organize-imports.importorder r1596095 for the Eclipse settings: #Organize Import Order #Sun May 18 22:45:33 EDT 2014 6=\#org.junit.Assert 5=\#org.hamcrest.CoreMatchers 4=\#org.easymock.EasyMock 3=com 2=org 1=javax 0=java git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1596225 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 index 8b4497b..d6f39da 100644 --- 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 @@ -17,10 +17,6 @@ */ package org.apache.logging.slf4j; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.util.Date; import java.util.List; @@ -41,6 +37,8 @@ import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.testUtil.StringListAppender; +import static org.junit.Assert.*; + /** * */ From a033f3f0ae4157de64a0ec7093a006cf84dd3189 Mon Sep 17 00:00:00 2001 From: rpopma Date: Wed, 4 Jun 2014 13:26:46 +0000 Subject: [PATCH 101/363] LOG4J2-555 follow-up: renamed LoggerProvider interface to ExtendedLogger, renamed AbstractLoggerProvider back to AbstractLogger git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1600200 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 4 ++-- .../java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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 index 36ca012..baa4ec8 100644 --- 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 @@ -21,14 +21,14 @@ 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.AbstractLoggerProvider; +import org.apache.logging.log4j.spi.AbstractLogger; import org.slf4j.MarkerFactory; import org.slf4j.spi.LocationAwareLogger; /** * */ -public class SLF4JLogger extends AbstractLoggerProvider { +public class SLF4JLogger extends AbstractLogger { private static final long serialVersionUID = 1L; private final org.slf4j.Logger logger; 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 index 125ccea..7391aa9 100644 --- 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 @@ -21,7 +21,7 @@ import org.apache.logging.log4j.message.MessageFactory; import org.apache.logging.log4j.spi.LoggerContext; -import org.apache.logging.log4j.spi.LoggerProvider; +import org.apache.logging.log4j.spi.ExtendedLogger; import org.slf4j.LoggerFactory; /** @@ -36,7 +36,7 @@ public Object getExternalContext() { } @Override - public LoggerProvider getLogger(final String name) { + public ExtendedLogger getLogger(final String name) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, LoggerFactory.getLogger(name))); } @@ -44,7 +44,7 @@ public LoggerProvider getLogger(final String name) { } @Override - public LoggerProvider getLogger(final String name, final MessageFactory messageFactory) { + public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) { if (!loggers.containsKey(name)) { loggers.putIfAbsent(name, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); } From ec3e8cc92e18e04f345592ebf51a901611640d9c Mon Sep 17 00:00:00 2001 From: bbrouwer Date: Sat, 7 Jun 2014 01:47:53 +0000 Subject: [PATCH 102/363] Remove the deprecated org.apache.logging.log4j.Marker.getParent() git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1601053 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/logging/slf4j/SLF4JLogger.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 index baa4ec8..21b3b19 100644 --- 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 @@ -93,11 +93,15 @@ private org.slf4j.Marker getMarker(final Marker marker) { if (marker == null) { return null; } - final Marker parent = marker.getParent(); - final org.slf4j.Marker parentMarker = parent == null ? null : getMarker(parent); final org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName()); - if (parentMarker != null && !slf4jMarker.contains(parentMarker)) { - slf4jMarker.add(parentMarker); + 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; } From 907400bc511d6f5924c7e6e5a9ce241f7aa62c98 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 21 Jun 2014 22:52:13 +0000 Subject: [PATCH 103/363] [maven-release-plugin] prepare release log4j-2.0-rc2 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1604485 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b4728f9..daef9c3 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2-SNAPSHOT + 2.0-rc2 ../ log4j-to-slf4j From d88615787f75208fcbed184271d0c8f70a010651 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 21 Jun 2014 22:52:18 +0000 Subject: [PATCH 104/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1604487 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index daef9c3..cf73927 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2 + 2.0-SNAPSHOT ../ log4j-to-slf4j From 6845a93f6f9c193ff150e45e1b8bd6253a67d01d Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 21 Jun 2014 23:10:24 +0000 Subject: [PATCH 105/363] Revert release git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1604490 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cf73927..b4728f9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-SNAPSHOT + 2.0-rc2-SNAPSHOT ../ log4j-to-slf4j From 2cf5e3b595bdda1a56d6af11c941c937da97ccdf Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 21 Jun 2014 23:29:55 +0000 Subject: [PATCH 106/363] [maven-release-plugin] prepare release log4j-2.0-rc2 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1604492 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b4728f9..daef9c3 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2-SNAPSHOT + 2.0-rc2 ../ log4j-to-slf4j From dead3f629d4493fc8d45e3a747a6c9e1e577b2cd Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 21 Jun 2014 23:30:00 +0000 Subject: [PATCH 107/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1604494 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index daef9c3..cf73927 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-rc2 + 2.0-SNAPSHOT ../ log4j-to-slf4j From 891357468098c1d8dbd14a52083c5d4064b1a651 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Wed, 25 Jun 2014 04:28:49 +0000 Subject: [PATCH 108/363] Use final consistently. Some APIs had a mix of final and non-final params when all could be final. They now are. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1605260 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 21b3b19..921ab17 100644 --- 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 @@ -151,7 +151,7 @@ private boolean isEnabledFor(final Level level, final Marker marker) { } @Override - public void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) { + public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) { if (locationAwareLogger != null) { if (message instanceof LoggerNameAwareMessage) { ((LoggerNameAwareMessage) message).setLoggerName(getName()); From d5491c48f90faec48e0d5cb558837aa35f2459be Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 12 Jul 2014 23:25:04 +0000 Subject: [PATCH 109/363] [maven-release-plugin] prepare release log4j-2.0 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1610083 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cf73927..fdeb997 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0-SNAPSHOT + 2.0 ../ log4j-to-slf4j From a6460dca908f056d24b597ea36606445e2e299b4 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 12 Jul 2014 23:25:12 +0000 Subject: [PATCH 110/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1610085 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fdeb997..29d1b46 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0 + 2.1-SNAPSHOT ../ log4j-to-slf4j From 9033709f673fb3451f7b0236310a3c9ecc77d591 Mon Sep 17 00:00:00 2001 From: mattsicker Date: Sun, 20 Jul 2014 01:39:42 +0000 Subject: [PATCH 111/363] Add Provide-Capability metadata for OSGi. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1611988 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 29d1b46..b435104 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -86,6 +86,7 @@ org.apache.logging.slf4j + org.apache.logging.log4j.spi.LoggerContextFactory From 030363435f4959e7f7e217f9b7e82c94a57ec4dc Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 24 Jul 2014 15:00:25 +0000 Subject: [PATCH 112/363] version change from 2.1 to 2.0.1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1613156 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b435104..ddc1638 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1-SNAPSHOT + 2.0.1-SNAPSHOT ../ log4j-to-slf4j From 15be5ab4e0254a365f3b6e103b569d00cef6a61c Mon Sep 17 00:00:00 2001 From: mattsicker Date: Tue, 29 Jul 2014 23:11:19 +0000 Subject: [PATCH 113/363] [maven-release-plugin] prepare release log4j-2.0.1 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1614510 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ddc1638..f659819 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0.1-SNAPSHOT + 2.0.1 ../ log4j-to-slf4j From 6d9716ff7310cfbfe44f87a5d0125ea92b009445 Mon Sep 17 00:00:00 2001 From: mattsicker Date: Tue, 29 Jul 2014 23:11:26 +0000 Subject: [PATCH 114/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1614512 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f659819..98deaca 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0.1 + 2.0.2-SNAPSHOT ../ log4j-to-slf4j From df3ca9aef8c094e2031e83add4c66d158960822b Mon Sep 17 00:00:00 2001 From: mattsicker Date: Sun, 17 Aug 2014 03:37:06 +0000 Subject: [PATCH 115/363] [maven-release-plugin] prepare release log4j-2.0.2 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1618450 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 98deaca..cad4d21 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0.2-SNAPSHOT + 2.0.2 ../ log4j-to-slf4j From 88d2ddef9c0dbfc9863a4d75e0ea09e16876f149 Mon Sep 17 00:00:00 2001 From: mattsicker Date: Sun, 17 Aug 2014 03:37:12 +0000 Subject: [PATCH 116/363] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1618452 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cad4d21..b435104 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.0.2 + 2.1-SNAPSHOT ../ log4j-to-slf4j From f26ae591b2a90c69f3c4d50fac507a34d3c22668 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Wed, 20 Aug 2014 03:29:33 +0000 Subject: [PATCH 117/363] Refactor FindBugs version into one property. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1619028 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b435104..7856f60 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -164,7 +164,7 @@ org.codehaus.mojo findbugs-maven-plugin - 2.5.2 + ${findbugs.plugin.version} true -Duser.language=en From 8841763413aafe2bfabb9289a4bbabc37e15ac3b Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 21 Aug 2014 08:21:08 +0000 Subject: [PATCH 118/363] Update to Checkstyle 2.12.1 for all modules using a shared property for the version. git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk@1619308 13f79535-47bb-0310-9956-ffa450edef68 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7856f60..656c2d0 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -112,7 +112,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.7 + ${checkstyle.plugin.version} ${log4jParentDir}/checkstyle.xml From 4b4b926ee37aacfb9c35907113001f8a93e3b952 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 29 Aug 2014 09:33:45 -0400 Subject: [PATCH 119/363] Ignore: Maven target folder and Eclipse files and folders. --- log4j-to-slf4j/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 log4j-to-slf4j/.gitignore diff --git a/log4j-to-slf4j/.gitignore b/log4j-to-slf4j/.gitignore new file mode 100644 index 0000000..9f0fc21 --- /dev/null +++ b/log4j-to-slf4j/.gitignore @@ -0,0 +1,4 @@ +/.settings/ +/target/ +/.classpath +/.project From 6e2a93a9619a392c898e804b988e2de6b08ca796 Mon Sep 17 00:00:00 2001 From: mattsicker Date: Sun, 17 Aug 2014 03:37:08 +0000 Subject: [PATCH 120/363] [maven-release-plugin] copy for tag log4j-2.0.2 git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/log4j2/tags/log4j-2.0.2@1618451 13f79535-47bb-0310-9956-ffa450edef68 From c875d141c9fcca895b496248f4e9995a03fb97c6 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 30 Aug 2014 18:03:59 -0500 Subject: [PATCH 121/363] Add XSD info for maven site configs. - Also added component names where one wasn't there. --- log4j-to-slf4j/src/site/site.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/log4j-to-slf4j/src/site/site.xml b/log4j-to-slf4j/src/site/site.xml index 08ca886..0f2364e 100644 --- a/log4j-to-slf4j/src/site/site.xml +++ b/log4j-to-slf4j/src/site/site.xml @@ -15,7 +15,10 @@ limitations under the License. --> - + From 03f52737871a5d6df4e1cc560b7004cd761636a3 Mon Sep 17 00:00:00 2001 From: remko Date: Thu, 4 Sep 2014 23:33:11 +0900 Subject: [PATCH 122/363] LOG4J2-807: Fixed issue where log4j-to-slf4j did not work correctly with SLF4J Simple Logger --- .../java/org/apache/logging/slf4j/SLF4JLogger.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 index 921ab17..34f3bef 100644 --- 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 @@ -161,22 +161,22 @@ public void logMessage(final String fqcn, final Level level, final Marker marker } else { switch (level.getStandardLevel()) { case DEBUG : - logger.debug(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.debug(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case TRACE : - logger.trace(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.trace(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case INFO : - logger.info(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.info(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case WARN : - logger.warn(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.warn(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; case ERROR : - logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.error(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; default : - logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.error(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); break; } } From 44614d9057aa82cce72bc0ef807d60c82b6588fc Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Fri, 5 Sep 2014 12:13:36 -0500 Subject: [PATCH 123/363] Remove capability mumbo jumbo. - Using a lock in log4j-api (ProviderUtil) has prevented the need for this hack in OSGi. --- log4j-to-slf4j/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 656c2d0..128a6d8 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -86,7 +86,6 @@ org.apache.logging.slf4j - org.apache.logging.log4j.spi.LoggerContextFactory From 5bf26461ca8e41765ebc16beda17bbb0731e4e60 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 29 Sep 2014 09:20:50 -0400 Subject: [PATCH 124/363] Consistent POM descriptions. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 128a6d8..d4432a5 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -26,7 +26,7 @@ log4j-to-slf4j jar Apache Log4j to SLF4J Adapter - Binding between LOG4J 2 API and SLF4J + The Apache Log4j binding between the Log4j 2 API and SLF4J ${basedir}/.. SLF4J Documentation From 8f43eb7ff046228331a9445668db591cbe7d45a2 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 29 Sep 2014 12:32:00 -0400 Subject: [PATCH 125/363] Refactor JXR plugin version into a property ${jxr.plugin.version}. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index d4432a5..9db30c4 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -175,7 +175,7 @@ org.apache.maven.plugins maven-jxr-plugin - 2.3 + ${jxr.plugin.version} non-aggregate From d34a82f6cc8704c5fff42ed9a3dcf3fdf98a37e8 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 29 Sep 2014 12:56:03 -0400 Subject: [PATCH 126/363] Pick up JXR version from parent POM. --- log4j-to-slf4j/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 9db30c4..d33644a 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -175,7 +175,6 @@ org.apache.maven.plugins maven-jxr-plugin - ${jxr.plugin.version} non-aggregate From 27095b81489b3003971158b6fe8bdf3e2d01ccde Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 29 Sep 2014 13:14:47 -0400 Subject: [PATCH 127/363] Add version element back to JXR plugins in reporting sections, or Maven complains. POM inheritance does not work like I thought it did! --- log4j-to-slf4j/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index d33644a..9db30c4 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -175,6 +175,7 @@ org.apache.maven.plugins maven-jxr-plugin + ${jxr.plugin.version} non-aggregate From 09bbb99416054b417c20f32579c5b9a74daca920 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Tue, 30 Sep 2014 18:19:31 -0500 Subject: [PATCH 128/363] Remove custom javadoc tag configurations. --- log4j-to-slf4j/pom.xml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 9db30c4..369c7b6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -133,23 +133,6 @@ project --> false true - - - issue - a - JIRA issue: - - - doubt - a - Troublesome: - - - compare - a - Compare with: - - From d551529194a0fedb45d04380cd7ca01526f36099 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 13:26:26 -0500 Subject: [PATCH 129/363] Add test utilities to log4j-to-slf4j. --- .../logging/slf4j/InitialLoggerContext.java | 71 +++++++++++++++++++ .../org/apache/logging/slf4j/TestUtil.java | 47 ++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/InitialLoggerContext.java create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/InitialLoggerContext.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/InitialLoggerContext.java new file mode 100644 index 0000000..102e032 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/InitialLoggerContext.java @@ -0,0 +1,71 @@ +/* + * 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.GenericConfigurator; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.slf4j.LoggerFactory; + +/** + * JUnit {@link TestRule} similar to the TestRule in {@code log4j-core} of the same name. + * + * @since 2.1 + */ +public class InitialLoggerContext implements TestRule { + + private final String configLocation; + + private LoggerContext context; + + private String testClassName; + + public InitialLoggerContext(final String configLocation) { + this.configLocation = configLocation; + } + + @Override + public Statement apply(final Statement base, final Description description) { + testClassName = description.getClassName(); + return new Statement() { + @Override + public void evaluate() throws Throwable { + context = (LoggerContext) LoggerFactory.getILoggerFactory(); + final GenericConfigurator configurator = new JoranConfigurator(); + configurator.setContext(context); + configurator.doConfigure(configLocation); + base.evaluate(); + } + }; + } + + public LoggerContext getContext() { + return context; + } + + public Logger getLogger() { + return context.getLogger(testClassName); + } + + public Logger getLogger(final String name) { + return context.getLogger(name); + } +} 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 new file mode 100644 index 0000000..d69ffa9 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java @@ -0,0 +1,47 @@ +/* + * 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 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 attachable = (AppenderAttachable) logger; + return getListAppender(attachable, name); + } + + public static StringListAppender getListAppender(final AppenderAttachable logger, final String name) { + return (StringListAppender) logger.getAppender(name); + } + + private TestUtil() { + } +} From 4afb4c2fd792ad14bde58b00a4aef745101634da Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 13:27:30 -0500 Subject: [PATCH 130/363] Use ILC in test. --- log4j-to-slf4j/pom.xml | 5 ++ .../org/apache/logging/slf4j/LoggerTest.java | 55 +++++++------------ 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 369c7b6..ed63f40 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -62,6 +62,11 @@ junit test + + org.hamcrest + hamcrest-all + test + 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 index d6f39da..8cb77df 100644 --- 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 @@ -20,6 +20,8 @@ import java.util.Date; import java.util.List; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.ThreadContext; @@ -27,16 +29,12 @@ import org.apache.logging.log4j.message.ParameterizedMessageFactory; import org.apache.logging.log4j.message.StringFormatterMessageFactory; import org.junit.Before; -import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.joran.JoranConfigurator; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.testUtil.StringListAppender; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.theInstance; import static org.junit.Assert.*; /** @@ -45,36 +43,23 @@ public class LoggerTest { private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; - private static Logger logger; - private static org.slf4j.Logger slf4jLogger; - private static LoggerContext context; - private static Logger root; - private static ch.qos.logback.classic.Logger rootLogger; - private static StringListAppender list; - - @BeforeClass - public static void setupClass() throws Exception { - slf4jLogger = LoggerFactory.getLogger(LoggerTest.class); - context = ((ch.qos.logback.classic.Logger) slf4jLogger).getLoggerContext(); - configure(CONFIG); - logger = LogManager.getLogger(LoggerTest.class); - assertTrue("Incorrect SLF4J Logger", ((SLF4JLogger) logger).getLogger() == slf4jLogger); - root = LogManager.getRootLogger(); - rootLogger = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); - list = (StringListAppender) rootLogger.getAppender("LIST"); - rootLogger.detachAppender("console"); - } - private static void configure(final String file) throws JoranException { - final JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(context); - jc.doConfigure(file); - } + @ClassRule + public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG); + + private Logger logger; + private StringListAppender list; @Before - public void before() { - assertNotNull(list); - assertNotNull(list.strList); + public void setUp() throws Exception { + final org.slf4j.Logger slf4jLogger = CTX.getLogger(); + logger = LogManager.getLogger(); + assertThat(slf4jLogger, is(theInstance(((SLF4JLogger) logger).getLogger()))); + final ch.qos.logback.classic.Logger rootLogger = CTX.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(); } From ebba69e1c6a99041dc98b306322614759e09f6ff Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 13:27:45 -0500 Subject: [PATCH 131/363] Add CallerInformationTest to log4j-to-slf4j. --- .../logging/slf4j/CallerInformationTest.java | 65 +++++++++++++++++++ .../test/resources/logback-calling-class.xml | 38 +++++++++++ 2 files changed, 103 insertions(+) create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java create mode 100644 log4j-to-slf4j/src/test/resources/logback-calling-class.xml 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 new file mode 100644 index 0000000..e1d7d64 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java @@ -0,0 +1,65 @@ +/* + * 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 ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; +import org.apache.logging.log4j.LogManager; +import org.junit.ClassRule; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CallerInformationTest { + + private static final String CONFIG = "target/test-classes/logback-calling-class.xml"; + + @ClassRule + public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG); + + @Test + public void testClassLogger() throws Exception { + final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger"); + final StringListAppender 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 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 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 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/resources/logback-calling-class.xml b/log4j-to-slf4j/src/test/resources/logback-calling-class.xml new file mode 100644 index 0000000..3251c7f --- /dev/null +++ b/log4j-to-slf4j/src/test/resources/logback-calling-class.xml @@ -0,0 +1,38 @@ + + + + + + + + %class + + + + + + + + + %method + + + + + + From b794e5dbea1d04b53e6a7eeff276cacd5e18da01 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 13:41:59 -0500 Subject: [PATCH 132/363] Literate tests. --- .../org/apache/logging/slf4j/LoggerTest.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) 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 index 8cb77df..e39c47c 100644 --- 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 @@ -32,9 +32,7 @@ import org.junit.ClassRule; import org.junit.Test; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.theInstance; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; /** @@ -67,20 +65,20 @@ public void setUp() throws Exception { public void basicFlow() { logger.entry(); logger.exit(); - assertTrue("Incorrect number of events. Expected 2, actual " + list.strList.size(), list.strList.size() == 2); + assertThat(list.strList, hasSize(2)); } @Test public void simpleFlow() { logger.entry(CONFIG); logger.exit(0); - assertTrue("Incorrect number of events. Expected 2, actual " + list.strList.size(), list.strList.size() == 2); + assertThat(list.strList, hasSize(2)); } @Test public void throwing() { logger.throwing(new IllegalArgumentException("Test Exception")); - assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + assertThat(list.strList, hasSize(1)); } @Test @@ -90,13 +88,13 @@ public void catching() { } catch (final Exception e) { logger.catching(e); } - assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + assertThat(list.strList, hasSize(1)); } @Test public void debug() { logger.debug("Debug message"); - assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + assertThat(list.strList, hasSize(1)); } @Test @@ -104,8 +102,8 @@ public void getLogger_String_MessageFactoryMismatch() { final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatch", StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE); testLogger.debug("%,d", Integer.MAX_VALUE); - assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); - assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0)); + assertThat(list.strList, hasSize(1)); + assertThat(list.strList, hasItem(String.format("%,d", Integer.MAX_VALUE))); } @Test @@ -113,47 +111,49 @@ public void getLogger_String_MessageFactoryMismatchNull() { final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull", StringFormatterMessageFactory.INSTANCE, null); testLogger.debug("%,d", Integer.MAX_VALUE); - assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); - assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0)); + 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); - assertNotNull(testLogger); - assertEquals(messageFactory1, testLogger.getMessageFactory()); + assertThat(testLogger, is(notNullValue())); + assertThat(testLogger.getMessageFactory(), equalTo(messageFactory1)); final Logger testLogger2 = LogManager.getLogger(name, messageFactory2); - assertEquals(messageFactory1, testLogger2.getMessageFactory()); + assertThat(testLogger2.getMessageFactory(), equalTo(messageFactory1)); return testLogger; } @Test public void debugObject() { logger.debug(new Date()); - assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + assertThat(list.strList, hasSize(1)); } @Test public void debugWithParms() { logger.debug("Hello, {}", "World"); - assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1); + assertThat(list.strList, hasSize(1)); } @Test public void testImpliedThrowable() { logger.debug("This is a test", new Throwable("Testing")); final List msgs = list.strList; - assertTrue("Incorrect number of messages. Expected 1, actual " + msgs.size(), msgs.size() == 1); + assertThat(msgs, hasSize(1)); final String expected = "java.lang.Throwable: Testing"; - assertTrue("Incorrect message data", msgs.get(0).contains(expected)); + assertThat(msgs, hasItem(containsString(expected))); } + + @SuppressWarnings("unchecked") @Test public void mdc() { - ThreadContext.put("TestYear", new Integer(2010).toString()); + ThreadContext.put("TestYear", Integer.toString(2010)); logger.debug("Debug message"); ThreadContext.clearMap(); logger.debug("Debug message"); - assertTrue("Incorrect number of events. Expected 2, actual " + list.strList.size(), list.strList.size() == 2); - assertTrue("Incorrect year", list.strList.get(0).startsWith("2010")); + assertThat(list.strList, hasSize(2)); + assertThat(list.strList, hasItems(startsWith("2010"), not(startsWith("2010")))); } } From 4c401c8c5c04c58392f33fca703c3c072503af00 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 14:18:55 -0500 Subject: [PATCH 133/363] [maven-release-plugin] prepare release log4j-2.1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ed63f40..33f3e50 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1-SNAPSHOT + 2.1 ../ log4j-to-slf4j From 4716aa691af6fa361018026aa15d38f69b8b8f15 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 14:19:03 -0500 Subject: [PATCH 134/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 33f3e50..0516f13 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1 + 2.2-SNAPSHOT ../ log4j-to-slf4j From f31237aee2c531cb2b6bae0b069b3172a2c84c7d Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 15:34:25 -0500 Subject: [PATCH 135/363] [maven-release-plugin] prepare release log4j-2.1-rc3 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0516f13..33f3e50 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.2-SNAPSHOT + 2.1 ../ log4j-to-slf4j From 6144b5282073ba4844bec0f45002d83957a6674b Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 15:34:32 -0500 Subject: [PATCH 136/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 33f3e50..0516f13 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1 + 2.2-SNAPSHOT ../ log4j-to-slf4j From 1f7aea121922145387a6efb5b4f4eba04bae5217 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 17:20:43 -0500 Subject: [PATCH 137/363] Normalize reporting sections in poms. --- log4j-to-slf4j/pom.xml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0516f13..e4e85f1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -111,6 +111,7 @@ %URL%/show_bug.cgi?id=%ISSUE% + true @@ -131,7 +132,7 @@ maven-javadoc-plugin ${javadoc.plugin.version} - Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.
+ Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.

]]>
- - - -
From bd3559451e41aa3d1d2b03f8cd402a4f9cb52ba2 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 4 Oct 2014 17:32:33 -0500 Subject: [PATCH 138/363] Revert version to 2.1-SNAPSHOT. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e4e85f1..c972b9d 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.2-SNAPSHOT + 2.1-SNAPSHOT ../ log4j-to-slf4j From a6df4374ee37b516542b3e17559e3dfb33cd856c Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Mon, 6 Oct 2014 17:31:57 -0500 Subject: [PATCH 139/363] [maven-release-plugin] prepare release log4j-2.1-rc4 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c972b9d..c025185 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1-SNAPSHOT + 2.1 ../ log4j-to-slf4j From 24b849bda8d614d1a9d86db3e0f9ef7928e028d4 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Mon, 6 Oct 2014 17:32:03 -0500 Subject: [PATCH 140/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c025185..e4e85f1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1 + 2.2-SNAPSHOT ../ log4j-to-slf4j From 6d8f6b9797c745a354cdf844b52d7723b3e116e4 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 19 Oct 2014 12:39:53 -0700 Subject: [PATCH 141/363] Revert changes to unit tests that cause compilation errors in Java 6 --- .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index e39c47c..b309edb 100644 --- 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 @@ -142,7 +142,7 @@ public void testImpliedThrowable() { final List msgs = list.strList; assertThat(msgs, hasSize(1)); final String expected = "java.lang.Throwable: Testing"; - assertThat(msgs, hasItem(containsString(expected))); + assertTrue("Incorrect message data", msgs.get(0).contains(expected)); } @SuppressWarnings("unchecked") @@ -153,7 +153,7 @@ public void mdc() { ThreadContext.clearMap(); logger.debug("Debug message"); assertThat(list.strList, hasSize(2)); - assertThat(list.strList, hasItems(startsWith("2010"), not(startsWith("2010")))); + assertTrue("Incorrect year", list.strList.get(0).startsWith("2010")); } } From 7514aa387609aef4ba74591ed4b93cd2a15208e7 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 19 Oct 2014 17:25:56 -0700 Subject: [PATCH 142/363] [maven-release-plugin] prepare release log4j-2.1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e4e85f1..c025185 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.2-SNAPSHOT + 2.1 ../ log4j-to-slf4j From 9705279de6cb3cb4e30f237b5ecac950185bda01 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 19 Oct 2014 17:40:58 -0700 Subject: [PATCH 143/363] Revert release version --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c025185..c972b9d 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1 + 2.1-SNAPSHOT ../ log4j-to-slf4j From 291bb67a34438061e80e588c9068f623865f01a0 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 19 Oct 2014 18:38:00 -0700 Subject: [PATCH 144/363] [maven-release-plugin] prepare release log4j-2.1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c972b9d..c025185 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1-SNAPSHOT + 2.1 ../ log4j-to-slf4j From d10b2811c30bf81bd44f84c435bc3a0b9ac6b59e Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 19 Oct 2014 18:38:06 -0700 Subject: [PATCH 145/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c025185..fd14d35 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1 + 2.1.1-SNAPSHOT ../ log4j-to-slf4j From 32780c42ddd7720a444795d04b7f9f0868bd8747 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 18 Nov 2014 01:10:10 -0500 Subject: [PATCH 146/363] Marking next version as 2.2 due to new features: connect timeouts on socket and syslog appenders and likely more to come. Previously, we only had bug fixes and updates. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fd14d35..e4e85f1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.1.1-SNAPSHOT + 2.2-SNAPSHOT ../ log4j-to-slf4j From b381d970987e289f61ea98ba47cf8a811f6f7b39 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 22 Feb 2015 15:16:35 -0700 Subject: [PATCH 147/363] [maven-release-plugin] prepare release log4j-2.2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e4e85f1..75ab987 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.2-SNAPSHOT + 2.2 ../ log4j-to-slf4j From b5c796af100e7290f7731b06895c4eb5b4a98a52 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 22 Feb 2015 15:16:39 -0700 Subject: [PATCH 148/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 75ab987..b631c97 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.2 + 2.2.1-SNAPSHOT ../ log4j-to-slf4j From 9ea477983fcc8dd36efd3114132550b09b8a1278 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 9 Mar 2015 15:01:16 -0700 Subject: [PATCH 149/363] [LOG4J2-926] Truncate from the end of text format modifier. Also change next version to 2.2 in changes.xml since this is a new minor feature. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b631c97..e4e85f1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.2.1-SNAPSHOT + 2.2-SNAPSHOT ../ log4j-to-slf4j From 1ca160790d51156a87cebac56b53f37dc4f01691 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 9 Mar 2015 15:13:14 -0700 Subject: [PATCH 150/363] I mean 2.3, not 2.2! [LOG4J2-926] Truncate from the end of text format modifier. Also change next version to 2.3 in changes.xml since this is a new minor feature. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e4e85f1..0abf468 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.2-SNAPSHOT + 2.3-SNAPSHOT ../ log4j-to-slf4j From 8dacb103ca6fa5c58041c3e81f6b14610fcc1b06 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 10 May 2015 12:55:35 -0700 Subject: [PATCH 151/363] [maven-release-plugin] prepare release log4j-2.3 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0abf468..5261949 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.3-SNAPSHOT + 2.3 ../ log4j-to-slf4j From a53e2f0e087d8801b079a7bc7721894d5167bbf4 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 10 May 2015 12:55:42 -0700 Subject: [PATCH 152/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5261949..b324aa6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.3 + 2.3.1-SNAPSHOT ../ log4j-to-slf4j From e63a1960648d16ab5f714fb5637f605a2ebaba4d Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 10 May 2015 13:53:36 -0700 Subject: [PATCH 153/363] Revert version for re-relesae. Add missing license headers --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b324aa6..0abf468 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.3.1-SNAPSHOT + 2.3-SNAPSHOT ../ log4j-to-slf4j From 120d8dd476322746f46bc55c2c0b0ea5731827fd Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 10 May 2015 14:12:18 -0700 Subject: [PATCH 154/363] [maven-release-plugin] prepare release log4j-2.3 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0abf468..5261949 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.3-SNAPSHOT + 2.3 ../ log4j-to-slf4j From c7c5cb2b6795c7713aa58451fd4484a595e91bf5 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 10 May 2015 14:12:22 -0700 Subject: [PATCH 155/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5261949..b324aa6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.3 + 2.3.1-SNAPSHOT ../ log4j-to-slf4j From 83c6151719f0533cd5c1cd6b328c1fec4e007838 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 19 May 2015 08:32:18 -0700 Subject: [PATCH 156/363] Bump version from 2.3.1 to 2.4 for the next release. We have a new platform requirment: Java 7 (instead of Java 6), two minor new features, and a few small bug fixes so far. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b324aa6..818867b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.3.1-SNAPSHOT + 2.4-SNAPSHOT ../ log4j-to-slf4j From de7356bcdbb307298a1d8caaafa8325dc5ff3d10 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 21 May 2015 11:14:53 -0700 Subject: [PATCH 157/363] Redundant specification of type arguments. --- .../main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 7391aa9..95fb776 100644 --- 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 @@ -28,7 +28,7 @@ * */ public class SLF4JLoggerContext implements LoggerContext { - private final ConcurrentMap loggers = new ConcurrentHashMap(); + private final ConcurrentMap loggers = new ConcurrentHashMap<>(); @Override public Object getExternalContext() { From f333b73bf68125eb6913267a748134be1a357034 Mon Sep 17 00:00:00 2001 From: rpopma Date: Sun, 5 Jul 2015 23:39:54 +0900 Subject: [PATCH 158/363] LOG4J2-1017 doc updates for new Java 7 requirement from log4j-2.4: - add mention in Runtime Dependencies page - add mention in log4j-api and log4j-core component top page - remove mention of java 6 from other component top pages; instead mention dependency on log4j-api/core --- log4j-to-slf4j/src/site/xdoc/index.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/src/site/xdoc/index.xml b/log4j-to-slf4j/src/site/xdoc/index.xml index 90697f6..181c73b 100644 --- a/log4j-to-slf4j/src/site/xdoc/index.xml +++ b/log4j-to-slf4j/src/site/xdoc/index.xml @@ -36,7 +36,7 @@

- The Log4j 2 to SLF4J adapter requires at least Java 6. + The Log4j 2 to SLF4J adapter is dependent on the Log4j 2 API and the SLF4J API.

From 854832212ceb450c1941a4a24f5cb4ef09caa203 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 20 Sep 2015 09:57:56 -0700 Subject: [PATCH 159/363] [maven-release-plugin] prepare release log4j-2.4 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 818867b..5dca264 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.4-SNAPSHOT + 2.4 ../ log4j-to-slf4j From c347386650f58de2bca2a541ca354cf5d2f7bf26 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 20 Sep 2015 09:58:02 -0700 Subject: [PATCH 160/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5dca264..0bbd3e1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.4 + 2.4.1-SNAPSHOT ../ log4j-to-slf4j From afe8e11f2a5305140e3f3432a243e1f2e66efbeb Mon Sep 17 00:00:00 2001 From: ggregory Date: Wed, 23 Sep 2015 20:09:45 -0700 Subject: [PATCH 161/363] Renamed InitialLoggerContext to LoggerContextRule. --- .../logging/slf4j/CallerInformationTest.java | 130 +++---- ...gerContext.java => LoggerContextRule.java} | 143 ++++---- .../org/apache/logging/slf4j/LoggerTest.java | 318 +++++++++--------- 3 files changed, 296 insertions(+), 295 deletions(-) rename log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/{InitialLoggerContext.java => LoggerContextRule.java} (90%) 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 index e1d7d64..7ebab7a 100644 --- 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 @@ -1,65 +1,65 @@ -/* - * 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 ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.testUtil.StringListAppender; -import org.apache.logging.log4j.LogManager; -import org.junit.ClassRule; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class CallerInformationTest { - - private static final String CONFIG = "target/test-classes/logback-calling-class.xml"; - - @ClassRule - public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG); - - @Test - public void testClassLogger() throws Exception { - final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger"); - final StringListAppender 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 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 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 messages = app.strList; - assertEquals("Incorrect number of messages.", 5, messages.size()); - for (final String message : messages) { - assertEquals("Incorrect caller method name.", "testMethodLogger", message); - } - } -} +/* + * 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 ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; +import org.apache.logging.log4j.LogManager; +import org.junit.ClassRule; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CallerInformationTest { + + private static final String CONFIG = "target/test-classes/logback-calling-class.xml"; + + @ClassRule + public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); + + @Test + public void testClassLogger() throws Exception { + final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger"); + final StringListAppender 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 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 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 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/InitialLoggerContext.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java similarity index 90% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/InitialLoggerContext.java rename to log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java index 102e032..0f245e2 100644 --- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/InitialLoggerContext.java +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java @@ -1,71 +1,72 @@ -/* - * 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.GenericConfigurator; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.slf4j.LoggerFactory; - -/** - * JUnit {@link TestRule} similar to the TestRule in {@code log4j-core} of the same name. - * - * @since 2.1 - */ -public class InitialLoggerContext implements TestRule { - - private final String configLocation; - - private LoggerContext context; - - private String testClassName; - - public InitialLoggerContext(final String configLocation) { - this.configLocation = configLocation; - } - - @Override - public Statement apply(final Statement base, final Description description) { - testClassName = description.getClassName(); - return new Statement() { - @Override - public void evaluate() throws Throwable { - context = (LoggerContext) LoggerFactory.getILoggerFactory(); - final GenericConfigurator configurator = new JoranConfigurator(); - configurator.setContext(context); - configurator.doConfigure(configLocation); - base.evaluate(); - } - }; - } - - public LoggerContext getContext() { - return context; - } - - public Logger getLogger() { - return context.getLogger(testClassName); - } - - public Logger getLogger(final String name) { - return context.getLogger(name); - } -} +/* + * 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.GenericConfigurator; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.slf4j.LoggerFactory; + +/** + * JUnit {@link TestRule} similar to the TestRule in {@code log4j-core} of the same name. + * + * @since 2.1 + * @since 2.4.1 Renamed InitialLoggerContext to LoggerContextRule + */ +public class LoggerContextRule implements TestRule { + + private final String configLocation; + + private LoggerContext context; + + private String testClassName; + + public LoggerContextRule(final String configLocation) { + this.configLocation = configLocation; + } + + @Override + public Statement apply(final Statement base, final Description description) { + testClassName = description.getClassName(); + return new Statement() { + @Override + public void evaluate() throws Throwable { + context = (LoggerContext) LoggerFactory.getILoggerFactory(); + final GenericConfigurator configurator = new JoranConfigurator(); + configurator.setContext(context); + configurator.doConfigure(configLocation); + base.evaluate(); + } + }; + } + + public LoggerContext getContext() { + return context; + } + + public Logger getLogger() { + return context.getLogger(testClassName); + } + + public Logger getLogger(final String name) { + return context.getLogger(name); + } +} 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 index b309edb..fb30a1b 100644 --- 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 @@ -1,159 +1,159 @@ - -/* -* 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.Date; -import java.util.List; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.testUtil.StringListAppender; -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.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; - -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; - -/** - * - */ -public class LoggerTest { - - private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; - - @ClassRule - public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG); - - private Logger logger; - private StringListAppender list; - - @Before - public void setUp() throws Exception { - final org.slf4j.Logger slf4jLogger = CTX.getLogger(); - logger = LogManager.getLogger(); - assertThat(slf4jLogger, is(theInstance(((SLF4JLogger) logger).getLogger()))); - final ch.qos.logback.classic.Logger rootLogger = CTX.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.entry(); - logger.exit(); - assertThat(list.strList, hasSize(2)); - } - - @Test - public void simpleFlow() { - logger.entry(CONFIG); - logger.exit(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())); - assertThat(testLogger.getMessageFactory(), equalTo(messageFactory1)); - final Logger testLogger2 = LogManager.getLogger(name, messageFactory2); - assertThat(testLogger2.getMessageFactory(), equalTo(messageFactory1)); - return testLogger; - } - - @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)); - } - - @Test - public void testImpliedThrowable() { - logger.debug("This is a test", new Throwable("Testing")); - final List 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")); - } -} - + +/* +* 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.Date; +import java.util.List; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; +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.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + +/** + * + */ +public class LoggerTest { + + private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; + + @ClassRule + public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); + + private Logger logger; + private StringListAppender list; + + @Before + public void setUp() throws Exception { + final org.slf4j.Logger slf4jLogger = CTX.getLogger(); + logger = LogManager.getLogger(); + assertThat(slf4jLogger, is(theInstance(((SLF4JLogger) logger).getLogger()))); + final ch.qos.logback.classic.Logger rootLogger = CTX.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.entry(); + logger.exit(); + assertThat(list.strList, hasSize(2)); + } + + @Test + public void simpleFlow() { + logger.entry(CONFIG); + logger.exit(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())); + assertThat(testLogger.getMessageFactory(), equalTo(messageFactory1)); + final Logger testLogger2 = LogManager.getLogger(name, messageFactory2); + assertThat(testLogger2.getMessageFactory(), equalTo(messageFactory1)); + return testLogger; + } + + @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)); + } + + @Test + public void testImpliedThrowable() { + logger.debug("This is a test", new Throwable("Testing")); + final List 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")); + } +} + From 9bdebc463615f29044f162193bc2410e1ee0de01 Mon Sep 17 00:00:00 2001 From: rgoers Date: Thu, 8 Oct 2015 17:49:19 -0700 Subject: [PATCH 162/363] [maven-release-plugin] prepare release log4j-2.4.1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0bbd3e1..cb43e53 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.4.1-SNAPSHOT + 2.4.1 ../ log4j-to-slf4j From a122759741ec9f4a1f2ed1797839bdf07b282da3 Mon Sep 17 00:00:00 2001 From: rgoers Date: Thu, 8 Oct 2015 17:49:26 -0700 Subject: [PATCH 163/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cb43e53..a0b598b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.4.1 + 2.5-SNAPSHOT ../ log4j-to-slf4j From ceaeb5ff6768d1dc03efd5f8eb0599dd7c9085c2 Mon Sep 17 00:00:00 2001 From: rgoers Date: Thu, 8 Oct 2015 17:49:19 -0700 Subject: [PATCH 164/363] [maven-release-plugin] prepare release log4j-2.4.1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index a0b598b..cb43e53 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.5-SNAPSHOT + 2.4.1 ../ log4j-to-slf4j From fe9ac8239a97e32e59871dd737cd5f6cf4b2f2ff Mon Sep 17 00:00:00 2001 From: rgoers Date: Thu, 8 Oct 2015 17:49:26 -0700 Subject: [PATCH 165/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cb43e53..a0b598b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.4.1 + 2.5-SNAPSHOT ../ log4j-to-slf4j From 6bfc788777b3a2baacb9be7f4ba4c52febf63867 Mon Sep 17 00:00:00 2001 From: ggregory Date: Sun, 1 Nov 2015 19:14:17 -0800 Subject: [PATCH 166/363] [LOG4J2-1180] Logger cache does not account for message factory. --- .../apache/logging/slf4j/SLF4JLoggerContext.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 index 95fb776..c4e6a99 100644 --- 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 @@ -20,8 +20,9 @@ import java.util.concurrent.ConcurrentMap; import org.apache.logging.log4j.message.MessageFactory; -import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.ExtendedLogger; +import org.apache.logging.log4j.spi.LoggerContext; +import org.apache.logging.log4j.spi.LoggerContextKey; import org.slf4j.LoggerFactory; /** @@ -53,6 +54,16 @@ public ExtendedLogger getLogger(final String name, final MessageFactory messageF @Override public boolean hasLogger(final String name) { - return loggers.containsKey(name); + return loggers.containsKey(LoggerContextKey.create(name)); + } + + @Override + public boolean hasLogger(String name, MessageFactory messageFactory) { + return loggers.containsKey(LoggerContextKey.create(name, messageFactory)); + } + + @Override + public boolean hasLogger(String name, Class messageFactoryClass) { + return loggers.containsKey(LoggerContextKey.create(name, messageFactoryClass)); } } From a420d55fa5628f4e5ed281820de11e7d7901874e Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 6 Dec 2015 17:18:12 -0700 Subject: [PATCH 167/363] [maven-release-plugin] prepare release log4j-2.5-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index a0b598b..596b193 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.5-SNAPSHOT + 2.5 ../ log4j-to-slf4j From 4f01346de42ca24abe9f6679f5f03a1959946469 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 6 Dec 2015 17:18:19 -0700 Subject: [PATCH 168/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 596b193..b0443d6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.5 + 2.5.1-SNAPSHOT ../ log4j-to-slf4j From 269d91bb067c71c3cba913fcad30b6d7015e5a8d Mon Sep 17 00:00:00 2001 From: ggregory Date: Mon, 7 Dec 2015 20:08:24 -0500 Subject: [PATCH 169/363] Do not hide. --- .../slf4j/SLF4JLoggerContextFactory.java | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) 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 index 4cae70f..aec9458 100644 --- 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 @@ -1,62 +1,62 @@ -/* - * 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; - -/** - * - */ -public class SLF4JLoggerContextFactory implements LoggerContextFactory { - private static final StatusLogger LOGGER = StatusLogger.getLogger(); - private static LoggerContext context = new SLF4JLoggerContext(); - - public SLF4JLoggerContextFactory() { - // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) - boolean misconfigured = false; - try { - Class.forName("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 context) { - } -} +/* + * 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; + +/** + * + */ +public class SLF4JLoggerContextFactory implements LoggerContextFactory { + private static final StatusLogger LOGGER = StatusLogger.getLogger(); + private static LoggerContext context = new SLF4JLoggerContext(); + + public SLF4JLoggerContextFactory() { + // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) + boolean misconfigured = false; + try { + Class.forName("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) { + } +} From 96ddda1412532a23c75cf59d69a06d4b93769004 Mon Sep 17 00:00:00 2001 From: ggregory Date: Wed, 27 Jan 2016 11:23:45 -0800 Subject: [PATCH 170/363] Update POMs from 2.5.1-SNAPSHOT to 2.6-SNAPSHOT. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b0443d6..19bedfa 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.5.1-SNAPSHOT + 2.6-SNAPSHOT ../ log4j-to-slf4j From 70a7ff61a03a846161f091b53505e80446423986 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Tue, 23 Feb 2016 23:35:08 -0600 Subject: [PATCH 171/363] Use LoaderUtil.loadClass instead of Class.forName --- .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index aec9458..2f20685 100644 --- 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 @@ -21,6 +21,7 @@ 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; /** * @@ -33,7 +34,7 @@ public SLF4JLoggerContextFactory() { // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) boolean misconfigured = false; try { - Class.forName("org.slf4j.helpers.Log4jLoggerFactory"); + LoaderUtil.loadClass("org.slf4j.helpers.Log4jLoggerFactory"); misconfigured = true; } catch (final ClassNotFoundException classNotFoundIsGood) { LOGGER.debug("org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good!"); From ae820a40c7fee88695df852e99c7164ccbb3daa8 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Wed, 2 Mar 2016 19:44:56 -0600 Subject: [PATCH 172/363] LOG4J2-1303 - Add dependency info link to component pages. --- log4j-to-slf4j/src/site/xdoc/index.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/log4j-to-slf4j/src/site/xdoc/index.xml b/log4j-to-slf4j/src/site/xdoc/index.xml index 181c73b..13bbcc9 100644 --- a/log4j-to-slf4j/src/site/xdoc/index.xml +++ b/log4j-to-slf4j/src/site/xdoc/index.xml @@ -37,6 +37,7 @@

The Log4j 2 to SLF4J adapter is dependent on the Log4j 2 API and the SLF4J API. + For more information, see Runtime Dependencies.

@@ -46,12 +47,12 @@ the logging implementation as required.

- Use of the SLF4J adapter (log4j-to-slf4j-2.0.jar) together with - the SLF4J bridge (log4j-slf4j-impl-2.0.jar) should + Use of the SLF4J adapter (log4j-to-slf4j-2.x.jar) together with + the SLF4J bridge (log4j-slf4j-impl-2.x.jar) should never be attempted as it will cause events to endlessly be routed between SLF4J and Log4j 2.

- \ No newline at end of file + From 9ec86938cccf6077759cfcd846c966deecc37e7d Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 17 Mar 2016 01:38:03 +1100 Subject: [PATCH 173/363] LOG4J2-1278 added methods with unrolled varargs to SLF4JLogger --- .../org/apache/logging/slf4j/SLF4JLogger.java | 72 ++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) 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 index 34f3bef..7ed81ed 100644 --- 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 @@ -45,7 +45,7 @@ public SLF4JLogger(final String name, final org.slf4j.Logger logger) { this.logger = logger; this.locationAwareLogger = logger instanceof LocationAwareLogger ? (LocationAwareLogger) logger : null; } - + private int convertLevel(final Level level) { switch (level.getStandardLevel()) { case DEBUG : @@ -84,7 +84,7 @@ public Level getLevel() { // Option: return Level.ALL; return Level.OFF; } - + public org.slf4j.Logger getLogger() { return locationAwareLogger != null ? locationAwareLogger : logger; } @@ -126,6 +126,74 @@ public boolean isEnabled(final Level level, final Marker marker, final String da 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); From e0eb76196ac58b12f23b475f549fa10c4046c612 Mon Sep 17 00:00:00 2001 From: rpopma Date: Sun, 27 Mar 2016 23:33:23 +0900 Subject: [PATCH 174/363] LOG4J2-1318 refactor LoggerContext implementations to use new LoggerRegistry data structure to avoid allocating temp objects. (No functional changes.) --- .../logging/slf4j/SLF4JLoggerContext.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) 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 index c4e6a99..7923b2b 100644 --- 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 @@ -16,20 +16,17 @@ */ package org.apache.logging.slf4j; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - 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.LoggerContextKey; +import org.apache.logging.log4j.spi.LoggerRegistry; import org.slf4j.LoggerFactory; /** * */ public class SLF4JLoggerContext implements LoggerContext { - private final ConcurrentMap loggers = new ConcurrentHashMap<>(); + private final LoggerRegistry loggerRegistry = new LoggerRegistry<>(); @Override public Object getExternalContext() { @@ -38,32 +35,39 @@ public Object getExternalContext() { @Override public ExtendedLogger getLogger(final String name) { - if (!loggers.containsKey(name)) { - loggers.putIfAbsent(name, new SLF4JLogger(name, LoggerFactory.getLogger(name))); + if (!loggerRegistry.hasLogger(name)) { + loggerRegistry.putIfAbsent(name, null, new SLF4JLogger(name, LoggerFactory.getLogger(name))); } - return loggers.get(name); + return loggerRegistry.getLogger(name); } @Override public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) { - if (!loggers.containsKey(name)) { - loggers.putIfAbsent(name, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); + // FIXME according to LOG4J2-1180, the below line should be: + // FIXME if (!loggerRegistry.hasLogger(name, messageFactory)) { + if (!loggerRegistry.hasLogger(name)) { + // FIXME: should be loggerRegistry.putIfAbsent(name, messageFactory, + loggerRegistry.putIfAbsent(name, null, + new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); } - return loggers.get(name); + // FIXME should be return loggerRegistry.getLogger(name, messageFactory); + return loggerRegistry.getLogger(name); + + // TODO applying the above fixes causes (log4j-to-slf4j) LoggerTest to fail } @Override public boolean hasLogger(final String name) { - return loggers.containsKey(LoggerContextKey.create(name)); + return loggerRegistry.hasLogger(name); } @Override public boolean hasLogger(String name, MessageFactory messageFactory) { - return loggers.containsKey(LoggerContextKey.create(name, messageFactory)); + return loggerRegistry.hasLogger(name, messageFactory); } @Override public boolean hasLogger(String name, Class messageFactoryClass) { - return loggers.containsKey(LoggerContextKey.create(name, messageFactoryClass)); + return loggerRegistry.hasLogger(name, messageFactoryClass); } } From 49e1b15da58c40359f192b8fb215fc00fcdcc15e Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 31 Mar 2016 21:44:17 +0900 Subject: [PATCH 175/363] LOG4J2-1278 fixed test to take into account that message factory may be wrapped with a MessageFactory2Adapter --- .../org/apache/logging/slf4j/LoggerTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 index fb30a1b..c061782 100644 --- 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 @@ -28,6 +28,8 @@ 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.junit.Before; import org.junit.ClassRule; import org.junit.Test; @@ -118,12 +120,24 @@ public void getLogger_String_MessageFactoryMismatchNull() { private Logger testMessageFactoryMismatch(final String name, final MessageFactory messageFactory1, final MessageFactory messageFactory2) { final Logger testLogger = LogManager.getLogger(name, messageFactory1); assertThat(testLogger, is(notNullValue())); - assertThat(testLogger.getMessageFactory(), equalTo(messageFactory1)); + checkMessageFactory(messageFactory1, testLogger); final Logger testLogger2 = LogManager.getLogger(name, messageFactory2); - assertThat(testLogger2.getMessageFactory(), equalTo(messageFactory1)); + checkMessageFactory(messageFactory1, 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()); From bb9bd3fa88fd87f48b33bff6048f4f1ec02d02a7 Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 7 Apr 2016 22:15:43 +0900 Subject: [PATCH 176/363] LOG4J2-1326 add methods isEnabled that accepts a CharSequence to subclasses of AbstractLogger --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 5 +++++ 1 file changed, 5 insertions(+) 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 index 7ed81ed..33e40c1 100644 --- 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 @@ -111,6 +111,11 @@ public boolean isEnabled(final Level level, final Marker marker, final Message d 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); From 3c797ed38c03fcf1e532c581273459be85a0dc35 Mon Sep 17 00:00:00 2001 From: ggregory Date: Sun, 17 Apr 2016 16:45:12 -0700 Subject: [PATCH 177/363] Add traceEntry/Exit() tests. --- .../org/apache/logging/slf4j/LoggerTest.java | 360 +++++++++--------- 1 file changed, 187 insertions(+), 173 deletions(-) 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 index c061782..77b9c4e 100644 --- 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 @@ -1,173 +1,187 @@ - -/* -* 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.Date; -import java.util.List; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.testUtil.StringListAppender; -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.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; - -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; - -/** - * - */ -public class LoggerTest { - - private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; - - @ClassRule - public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); - - private Logger logger; - private StringListAppender list; - - @Before - public void setUp() throws Exception { - final org.slf4j.Logger slf4jLogger = CTX.getLogger(); - logger = LogManager.getLogger(); - assertThat(slf4jLogger, is(theInstance(((SLF4JLogger) logger).getLogger()))); - final ch.qos.logback.classic.Logger rootLogger = CTX.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.entry(); - logger.exit(); - assertThat(list.strList, hasSize(2)); - } - - @Test - public void simpleFlow() { - logger.entry(CONFIG); - logger.exit(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(messageFactory1, 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)); - } - - @Test - public void testImpliedThrowable() { - logger.debug("This is a test", new Throwable("Testing")); - final List 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")); - } -} - + +/* +* 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.Date; +import java.util.List; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; +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.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + +/** + * + */ +public class LoggerTest { + + private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; + + @ClassRule + public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); + + private Logger logger; + private StringListAppender list; + + @Before + public void setUp() throws Exception { + final org.slf4j.Logger slf4jLogger = CTX.getLogger(); + logger = LogManager.getLogger(); + assertThat(slf4jLogger, is(theInstance(((SLF4JLogger) logger).getLogger()))); + final ch.qos.logback.classic.Logger rootLogger = CTX.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(CONFIG); + logger.exit(0); + assertThat(list.strList, hasSize(2)); + } + + @Test + public void simpleFlow() { + logger.entry(CONFIG); + 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(messageFactory1, 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)); + } + + @Test + public void testImpliedThrowable() { + logger.debug("This is a test", new Throwable("Testing")); + final List 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")); + } +} + From 506a3e4ccb97a82d311d65392a68921e4b9ea366 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 25 May 2016 07:53:18 -0700 Subject: [PATCH 178/363] [maven-release-plugin] prepare release log4j-2.6-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 19bedfa..880b51c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6-SNAPSHOT + 2.6 ../ log4j-to-slf4j From 82a8cc5c493dc6cb3fb98150ee75399ae90d7624 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 25 May 2016 07:53:25 -0700 Subject: [PATCH 179/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 880b51c..764a539 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6 + 2.6.1-SNAPSHOT ../ log4j-to-slf4j From 2a504d9f1f0c779d23cc54a95335d10b1e4913d0 Mon Sep 17 00:00:00 2001 From: ggregory Date: Fri, 3 Jun 2016 11:17:55 -0700 Subject: [PATCH 180/363] Use final. --- .../java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 7923b2b..4c0120b 100644 --- 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 @@ -62,12 +62,12 @@ public boolean hasLogger(final String name) { } @Override - public boolean hasLogger(String name, MessageFactory messageFactory) { + public boolean hasLogger(final String name, final MessageFactory messageFactory) { return loggerRegistry.hasLogger(name, messageFactory); } @Override - public boolean hasLogger(String name, Class messageFactoryClass) { + public boolean hasLogger(final String name, final Class messageFactoryClass) { return loggerRegistry.hasLogger(name, messageFactoryClass); } } From b1d79adde2f13dfc3e70d91887bff9848b2c48da Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 5 Jun 2016 17:31:48 -0700 Subject: [PATCH 181/363] [maven-release-plugin] prepare release log4j-2.6.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 764a539..c586f5d 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6.1-SNAPSHOT + 2.6.1 ../ log4j-to-slf4j From 5bd603064fd2ef8c972c73ed6c5efc4b58b53d38 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 5 Jun 2016 17:31:58 -0700 Subject: [PATCH 182/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c586f5d..7c13741 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6.1 + 2.6.2-SNAPSHOT ../ log4j-to-slf4j From f56405053a4a7ee31777dbf05f99e23a737dcc0e Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 5 Jul 2016 19:35:19 -0700 Subject: [PATCH 183/363] [maven-release-plugin] prepare release log4j-2.6.2-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7c13741..bb6f404 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6.2-SNAPSHOT + 2.6.2 ../ log4j-to-slf4j From 21898c92f6ff5df6303cfc99b2728aca0875450d Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 5 Jul 2016 19:35:30 -0700 Subject: [PATCH 184/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index bb6f404..955bc04 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6.2 + 2.6.3-SNAPSHOT ../ log4j-to-slf4j From c1fb66812f5fd39a610610cfcaf6ecf367be7cb2 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 15 Aug 2016 15:00:05 -0700 Subject: [PATCH 185/363] [LOG4J2-1516] Add ThreadContextMap.putAll(Map). --- .../java/org/apache/logging/slf4j/MDCContextMap.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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 index 2636b74..b5c640f 100644 --- 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 @@ -17,6 +17,7 @@ package org.apache.logging.slf4j; import java.util.Map; +import java.util.Map.Entry; import org.apache.logging.log4j.spi.ThreadContextMap; import org.slf4j.MDC; @@ -25,11 +26,19 @@ * Bind the ThreadContextMap to the SLF4J MDC. */ public class MDCContextMap implements ThreadContextMap { + @Override public void put(final String key, final String value) { MDC.put(key, value); } + @Override + public void putAll(final Map m) { + for (Entry entry : m.entrySet()) { + MDC.put(entry.getKey(), entry.getValue()); + } + } + @Override public String get(final String key) { return MDC.get(key); From c3f33c7a47426f5e29a6096b58180f8f5fce1ca4 Mon Sep 17 00:00:00 2001 From: rpopma Date: Sat, 20 Aug 2016 09:00:38 +0900 Subject: [PATCH 186/363] LOG4J2-1516 moved putAll(Map) method into separate ThreadContextMap2 interface --- .../main/java/org/apache/logging/slf4j/MDCContextMap.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 index b5c640f..9b0251a 100644 --- 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 @@ -20,13 +20,14 @@ import java.util.Map.Entry; import org.apache.logging.log4j.spi.ThreadContextMap; +import org.apache.logging.log4j.spi.ThreadContextMap2; import org.slf4j.MDC; /** * Bind the ThreadContextMap to the SLF4J MDC. */ -public class MDCContextMap implements ThreadContextMap { - +public class MDCContextMap implements ThreadContextMap, ThreadContextMap2 { + @Override public void put(final String key, final String value) { MDC.put(key, value); @@ -35,7 +36,7 @@ public void put(final String key, final String value) { @Override public void putAll(final Map m) { for (Entry entry : m.entrySet()) { - MDC.put(entry.getKey(), entry.getValue()); + MDC.put(entry.getKey(), entry.getValue()); } } From 8a32ceef6c6eade5ff8e7edb590f4d327e260aa0 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 22 Aug 2016 15:58:13 -0700 Subject: [PATCH 187/363] ThreadContextMap2 extends ThreadContextMap. --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 9b0251a..4ec6896 100644 --- 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 @@ -26,7 +26,7 @@ /** * Bind the ThreadContextMap to the SLF4J MDC. */ -public class MDCContextMap implements ThreadContextMap, ThreadContextMap2 { +public class MDCContextMap implements ThreadContextMap2 { @Override public void put(final String key, final String value) { From f171f78658189c51c8dc8da238d6c64f909aded0 Mon Sep 17 00:00:00 2001 From: ggregory Date: Thu, 1 Sep 2016 08:13:15 -0700 Subject: [PATCH 188/363] Simplify Git ignore file usage. --- log4j-to-slf4j/.gitignore | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 log4j-to-slf4j/.gitignore diff --git a/log4j-to-slf4j/.gitignore b/log4j-to-slf4j/.gitignore deleted file mode 100644 index 9f0fc21..0000000 --- a/log4j-to-slf4j/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/.settings/ -/target/ -/.classpath -/.project From ae9262357c02df842c2e878299ee05cf2a4bb218 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 6 Sep 2016 17:44:48 -0400 Subject: [PATCH 189/363] Remove unused imports. --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 1 - 1 file changed, 1 deletion(-) 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 index 4ec6896..afc950d 100644 --- 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 @@ -19,7 +19,6 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.spi.ThreadContextMap; import org.apache.logging.log4j.spi.ThreadContextMap2; import org.slf4j.MDC; From 1189db06e65605f6253fa55ab8cda6650a3ee4ed Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 6 Sep 2016 23:01:19 -0400 Subject: [PATCH 190/363] Add final modifier to local variables. --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index afc950d..5202ca7 100644 --- 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 @@ -34,7 +34,7 @@ public void put(final String key, final String value) { @Override public void putAll(final Map m) { - for (Entry entry : m.entrySet()) { + for (final Entry entry : m.entrySet()) { MDC.put(entry.getKey(), entry.getValue()); } } From 1142ed7de8a60dcdcb4a409181b17f4b7d84a94e Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 22 Sep 2016 11:01:26 +0900 Subject: [PATCH 191/363] LOG4J2-1447 change the contract of ThreadContextMap2 to include the role of MutableContextDataSupplier --- .../apache/logging/slf4j/MDCContextMap.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 index 5202ca7..0593e3c 100644 --- 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 @@ -19,7 +19,9 @@ import java.util.Map; import java.util.Map.Entry; +import org.apache.logging.log4j.spi.MutableContextData; import org.apache.logging.log4j.spi.ThreadContextMap2; +import org.apache.logging.log4j.util.ArrayContextData; import org.slf4j.MDC; /** @@ -27,6 +29,11 @@ */ public class MDCContextMap implements ThreadContextMap2 { + private static final MutableContextData EMPTY_CONTEXT_DATA = new ArrayContextData(); + static { + EMPTY_CONTEXT_DATA.freeze(); + } + @Override public void put(final String key, final String value) { MDC.put(key, value); @@ -75,4 +82,17 @@ public Map getImmutableMapOrNull() { public boolean isEmpty() { return MDC.getCopyOfContextMap().isEmpty(); } + + @Override + public MutableContextData getMutableContextData() { + final Map copy = getCopy(); + if (copy.isEmpty()) { + return EMPTY_CONTEXT_DATA; + } + final MutableContextData result = new ArrayContextData(); + for (Entry entry : copy.entrySet()) { + result.putValue(entry.getKey(), entry.getValue()); + } + return result; + } } From a5b30dc787076395a61b11f3c16b6644b07053b4 Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 22 Sep 2016 21:38:33 +0900 Subject: [PATCH 192/363] LOG4J2-1447 LOG4J2-1349 renamed ArrayContextData to SortedStringArrayMap --- .../main/java/org/apache/logging/slf4j/MDCContextMap.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 index 0593e3c..a96537f 100644 --- 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 @@ -21,7 +21,7 @@ import org.apache.logging.log4j.spi.MutableContextData; import org.apache.logging.log4j.spi.ThreadContextMap2; -import org.apache.logging.log4j.util.ArrayContextData; +import org.apache.logging.log4j.util.SortedStringArrayMap; import org.slf4j.MDC; /** @@ -29,7 +29,7 @@ */ public class MDCContextMap implements ThreadContextMap2 { - private static final MutableContextData EMPTY_CONTEXT_DATA = new ArrayContextData(); + private static final MutableContextData EMPTY_CONTEXT_DATA = new SortedStringArrayMap(); static { EMPTY_CONTEXT_DATA.freeze(); } @@ -89,7 +89,7 @@ public MutableContextData getMutableContextData() { if (copy.isEmpty()) { return EMPTY_CONTEXT_DATA; } - final MutableContextData result = new ArrayContextData(); + final MutableContextData result = new SortedStringArrayMap(); for (Entry entry : copy.entrySet()) { result.putValue(entry.getKey(), entry.getValue()); } From f735f1927251f0db8ed0f2d2d2f4ca797cee9f82 Mon Sep 17 00:00:00 2001 From: rpopma Date: Thu, 22 Sep 2016 23:03:55 +0900 Subject: [PATCH 193/363] LOG4J2-1349 documented and renamed method getReadOnlyContextData() to clarify its intended usage --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index a96537f..b709af8 100644 --- 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 @@ -84,7 +84,7 @@ public boolean isEmpty() { } @Override - public MutableContextData getMutableContextData() { + public MutableContextData getReadOnlyContextData() { final Map copy = getCopy(); if (copy.isEmpty()) { return EMPTY_CONTEXT_DATA; From 1246f5f36fe1e185d81602d2899d6dc40873a445 Mon Sep 17 00:00:00 2001 From: rpopma Date: Fri, 23 Sep 2016 00:52:55 +0900 Subject: [PATCH 194/363] LOG4J2-1447 LOG4J2-1349 moved ContextData and MutableContextData from spi package to util package --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index b709af8..e048896 100644 --- 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 @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.spi.MutableContextData; +import org.apache.logging.log4j.util.MutableContextData; import org.apache.logging.log4j.spi.ThreadContextMap2; import org.apache.logging.log4j.util.SortedStringArrayMap; import org.slf4j.MDC; From bf5b84161483d909e4ba09940b5cb62d821ba6f2 Mon Sep 17 00:00:00 2001 From: rpopma Date: Fri, 23 Sep 2016 01:58:26 +0900 Subject: [PATCH 195/363] LOG4J2-1447 LOG4J2-1349 renamed MutableContextData to StringMap, ContextData to ReadOnlyStringMap --- .../java/org/apache/logging/slf4j/MDCContextMap.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 index e048896..6b0f3ae 100644 --- 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 @@ -19,9 +19,9 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.util.MutableContextData; +import org.apache.logging.log4j.util.StringMap; import org.apache.logging.log4j.spi.ThreadContextMap2; -import org.apache.logging.log4j.util.SortedStringArrayMap; +import org.apache.logging.log4j.util.SortedArrayStringMap; import org.slf4j.MDC; /** @@ -29,7 +29,7 @@ */ public class MDCContextMap implements ThreadContextMap2 { - private static final MutableContextData EMPTY_CONTEXT_DATA = new SortedStringArrayMap(); + private static final StringMap EMPTY_CONTEXT_DATA = new SortedArrayStringMap(); static { EMPTY_CONTEXT_DATA.freeze(); } @@ -84,12 +84,12 @@ public boolean isEmpty() { } @Override - public MutableContextData getReadOnlyContextData() { + public StringMap getReadOnlyContextData() { final Map copy = getCopy(); if (copy.isEmpty()) { return EMPTY_CONTEXT_DATA; } - final MutableContextData result = new SortedStringArrayMap(); + final StringMap result = new SortedArrayStringMap(); for (Entry entry : copy.entrySet()) { result.putValue(entry.getKey(), entry.getValue()); } From 3b85eff5a3bfb102abb469cf5ad4b819968b8b3f Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 25 Sep 2016 20:09:13 -0700 Subject: [PATCH 196/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 955bc04..e95de69 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6.3-SNAPSHOT + 2.7.1-SNAPSHOT ../ log4j-to-slf4j From f403040d1906ee9ebc01d4d9b9b0fea3c70116ec Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 25 Sep 2016 20:22:21 -0700 Subject: [PATCH 197/363] [maven-release-plugin] rollback the release of log4j-2.7-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e95de69..955bc04 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.7.1-SNAPSHOT + 2.6.3-SNAPSHOT ../ log4j-to-slf4j From 2182866423db8450909eda6fb1498043a3e8814d Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 25 Sep 2016 23:37:53 -0700 Subject: [PATCH 198/363] [maven-release-plugin] prepare release log4j-2.7-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 955bc04..eb45f64 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.6.3-SNAPSHOT + 2.7 ../ log4j-to-slf4j From aced526516818e623d0d0df02eac7ea727201bd3 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 25 Sep 2016 23:38:01 -0700 Subject: [PATCH 199/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index eb45f64..e95de69 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.7 + 2.7.1-SNAPSHOT ../ log4j-to-slf4j From ee990093035418dd6a1bcf0a6d2125e7e2444626 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 2 Oct 2016 11:13:11 -0700 Subject: [PATCH 200/363] [maven-release-plugin] prepare release log4j-2.7-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e95de69..eb45f64 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.7.1-SNAPSHOT + 2.7 ../ log4j-to-slf4j From afae3f539f2cb81e7c89041c7d75cdb2395e4230 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 2 Oct 2016 11:13:19 -0700 Subject: [PATCH 201/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index eb45f64..e95de69 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.7 + 2.7.1-SNAPSHOT ../ log4j-to-slf4j From c888f9dc1104bf59ebc73a7d6e386a1c0e9ec301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20St=C3=A5ldal?= Date: Fri, 21 Oct 2016 22:34:04 +0200 Subject: [PATCH 202/363] Immutable empty StringMap --- .../main/java/org/apache/logging/slf4j/MDCContextMap.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 index 6b0f3ae..cb3a349 100644 --- 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 @@ -19,6 +19,7 @@ import java.util.Map; import java.util.Map.Entry; +import org.apache.logging.log4j.util.EmptyFrozenStringMap; import org.apache.logging.log4j.util.StringMap; import org.apache.logging.log4j.spi.ThreadContextMap2; import org.apache.logging.log4j.util.SortedArrayStringMap; @@ -29,11 +30,6 @@ */ public class MDCContextMap implements ThreadContextMap2 { - private static final StringMap EMPTY_CONTEXT_DATA = new SortedArrayStringMap(); - static { - EMPTY_CONTEXT_DATA.freeze(); - } - @Override public void put(final String key, final String value) { MDC.put(key, value); @@ -87,7 +83,7 @@ public boolean isEmpty() { public StringMap getReadOnlyContextData() { final Map copy = getCopy(); if (copy.isEmpty()) { - return EMPTY_CONTEXT_DATA; + return EmptyFrozenStringMap.INSTANCE; } final StringMap result = new SortedArrayStringMap(); for (Entry entry : copy.entrySet()) { From f301d18406139eced097b05b0d5446b22b15f9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20St=C3=A5ldal?= Date: Mon, 24 Oct 2016 10:14:45 +0200 Subject: [PATCH 203/363] Remove EmptyStringMap class --- .../main/java/org/apache/logging/slf4j/MDCContextMap.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 index cb3a349..f41fdb6 100644 --- 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 @@ -19,7 +19,6 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.util.EmptyFrozenStringMap; import org.apache.logging.log4j.util.StringMap; import org.apache.logging.log4j.spi.ThreadContextMap2; import org.apache.logging.log4j.util.SortedArrayStringMap; @@ -30,6 +29,11 @@ */ public class MDCContextMap implements ThreadContextMap2 { + 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); @@ -83,7 +87,7 @@ public boolean isEmpty() { public StringMap getReadOnlyContextData() { final Map copy = getCopy(); if (copy.isEmpty()) { - return EmptyFrozenStringMap.INSTANCE; + return EMPTY_CONTEXT_DATA; } final StringMap result = new SortedArrayStringMap(); for (Entry entry : copy.entrySet()) { From d1733531bfa7923435b2fec1f307fb02b8bf881b Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 10 Nov 2016 13:31:20 -0800 Subject: [PATCH 204/363] Testing [LOG4J2-1688] Multiple loggings of arguments are setting these arguments to null --- .../logging/slf4j/Log4j2Jira1688Test.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java 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 new file mode 100644 index 0000000..7c9b561 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java @@ -0,0 +1,69 @@ +/* + * 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.Arrays; + +import org.junit.Assert; +import org.junit.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 = 33; + 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? + Assert.assertArrayEquals(originalArgs, args); + // System.out.println("args are still ok: " + Arrays.toString(args)); + + // Bug: The second logging of args sets all elements of args to null + logger.error(someFormat, args); + // System.out.println("args " + Arrays.toString(args)); + Assert.assertArrayEquals(originalArgs, args); + } + + /** + * @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; + } + +} From dfb901cf9d3853a9efe3f39b872076cff7e5a74e Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 10 Nov 2016 13:34:38 -0800 Subject: [PATCH 205/363] Add comments. --- .../java/org/apache/logging/slf4j/Log4j2Jira1688Test.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 index 7c9b561..46dbade 100644 --- 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 @@ -37,7 +37,7 @@ public void testLog4j2() { final Object[] args = createArray(limit); final Object[] originalArgs = Arrays.copyOf(args, args.length); - // System.out.println("args " + Arrays.toString(args)); + System.out.println("args " + Arrays.toString(args)); // Logger definition final String someFormat = "test {}"; @@ -45,12 +45,14 @@ public void testLog4j2() { // 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 Assert.assertArrayEquals(originalArgs, args); - // System.out.println("args are still ok: " + Arrays.toString(args)); + System.out.println("args are still ok: " + Arrays.toString(args)); // Bug: The second logging of args sets all elements of args to null logger.error(someFormat, args); - // System.out.println("args " + Arrays.toString(args)); + // GG: All is well args is still intact + System.out.println("args " + Arrays.toString(args)); Assert.assertArrayEquals(originalArgs, args); } From 49690a0d5ca471785abaefeccb7c1494c2aeead9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20St=C3=A5ldal?= Date: Fri, 11 Nov 2016 15:14:45 +0100 Subject: [PATCH 206/363] LOG4J2-1679 Add ThreadContextMap3 interface supporting method removeAll(Iterable) --- .../apache/logging/slf4j/MDCContextMap.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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 index f41fdb6..219323a 100644 --- 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 @@ -19,15 +19,15 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.util.StringMap; -import org.apache.logging.log4j.spi.ThreadContextMap2; +import org.apache.logging.log4j.spi.ThreadContextMap3; 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 ThreadContextMap2 { +public class MDCContextMap implements ThreadContextMap3 { private static final StringMap EMPTY_CONTEXT_DATA = new SortedArrayStringMap(1); static { @@ -41,9 +41,9 @@ public void put(final String key, final String value) { @Override public void putAll(final Map m) { - for (final Entry entry : m.entrySet()) { + for (final Entry entry : m.entrySet()) { MDC.put(entry.getKey(), entry.getValue()); - } + } } @Override @@ -56,6 +56,14 @@ public void remove(final String key) { MDC.remove(key); } + + @Override + public void removeAll(Iterable keys) { + for (final String key : keys) { + MDC.remove(key); + } + } + @Override public void clear() { MDC.clear(); From 3775aaf031847d7df1ff2439ffa23a1dfcc6b05f Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 11 Nov 2016 23:07:41 -0800 Subject: [PATCH 207/363] Primes have more fun. --- .../test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 46dbade..7f4cc1c 100644 --- 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 @@ -33,7 +33,7 @@ public class Log4j2Jira1688Test { public void testLog4j2() { // Argument-array creation - final int limit = 33; + final int limit = 37; final Object[] args = createArray(limit); final Object[] originalArgs = Arrays.copyOf(args, args.length); From cfc0e26fb758454246f11ae60aa01fac207a2c08 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 12 Nov 2016 01:11:40 -0800 Subject: [PATCH 208/363] Add final modifier to method parameters. --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 219323a..03b8564 100644 --- 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 @@ -58,7 +58,7 @@ public void remove(final String key) { @Override - public void removeAll(Iterable keys) { + public void removeAll(final Iterable keys) { for (final String key : keys) { MDC.remove(key); } From 3a98f64d5a0d124fd5de041e48d33de0576693cd Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 12 Nov 2016 01:12:21 -0800 Subject: [PATCH 209/363] Add final modifier to local variables --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 03b8564..964ac52 100644 --- 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 @@ -98,7 +98,7 @@ public StringMap getReadOnlyContextData() { return EMPTY_CONTEXT_DATA; } final StringMap result = new SortedArrayStringMap(); - for (Entry entry : copy.entrySet()) { + for (final Entry entry : copy.entrySet()) { result.putValue(entry.getKey(), entry.getValue()); } return result; From dde349232e55aca737eb41a19787a1d515f89a9e Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 15 Jan 2017 20:27:44 -0600 Subject: [PATCH 210/363] Configure maven-doap-plugin * Specify Ralph Goers as PMC Chair. * Add downloadUrl to distributionManagement. * Add project charter from website. * Reword submodule descriptions where necessary to satisfy plugin. * Enable doap plugin for site generation. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e95de69..2e3c77e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -26,7 +26,7 @@ log4j-to-slf4j jar Apache Log4j to SLF4J Adapter - The Apache Log4j binding between the Log4j 2 API and SLF4J + The Apache Log4j binding between Log4j 2 API and SLF4J. ${basedir}/.. SLF4J Documentation From 3a4013299344a2d988953b00d64044b75190c287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20St=C3=A5ldal?= Date: Tue, 17 Jan 2017 10:14:54 +0100 Subject: [PATCH 211/363] LOG4J2-1689 Rename to CleanableThreadContextMap --- .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 964ac52..f03ee54 100644 --- 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 @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.spi.ThreadContextMap3; +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; @@ -27,7 +27,7 @@ /** * Bind the ThreadContextMap to the SLF4J MDC. */ -public class MDCContextMap implements ThreadContextMap3 { +public class MDCContextMap implements CleanableThreadContextMap { private static final StringMap EMPTY_CONTEXT_DATA = new SortedArrayStringMap(1); static { From 2f72e33c2004e1d80db2b4b2a18214d1250ad08e Mon Sep 17 00:00:00 2001 From: rgoers Date: Sat, 21 Jan 2017 22:07:27 -0700 Subject: [PATCH 212/363] [maven-release-plugin] prepare release log4j-2.8-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 2e3c77e..892638b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.7.1-SNAPSHOT + 2.8 ../ log4j-to-slf4j From e9ede8f719b78377588bf19aec96845ca43e1b79 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sat, 21 Jan 2017 22:07:36 -0700 Subject: [PATCH 213/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 892638b..39097da 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.8 + 2.8.1-SNAPSHOT ../ log4j-to-slf4j From e240f3b8c285b33235d96191212755f59d66ca3d Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 21 Jan 2017 15:24:51 -0600 Subject: [PATCH 214/363] Migrate to logging-parent This also cleans up some unnecessary configs that are specified in the parent pom. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 39097da..5352d85 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -185,7 +185,7 @@ maven-pmd-plugin ${pmd.plugin.version} - ${maven.compile.target} + ${maven.compiler.target} From b4b0be29a14f744b5effc6ddcd0ccd0c413f5629 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 29 Jan 2017 15:48:59 -0600 Subject: [PATCH 215/363] [LOG4J2-1802]: Migrate component sites to markdown --- log4j-to-slf4j/src/site/markdown/index.md | 41 ++++++++++++++++ log4j-to-slf4j/src/site/xdoc/index.xml | 58 ----------------------- 2 files changed, 41 insertions(+), 58 deletions(-) create mode 100644 log4j-to-slf4j/src/site/markdown/index.md delete mode 100644 log4j-to-slf4j/src/site/xdoc/index.xml diff --git a/log4j-to-slf4j/src/site/markdown/index.md b/log4j-to-slf4j/src/site/markdown/index.md new file mode 100644 index 0000000..34027e7 --- /dev/null +++ b/log4j-to-slf4j/src/site/markdown/index.md @@ -0,0 +1,41 @@ + + + +# Log4j to SLF4J Adapter + +The Log4j 2 to SLF4J Adapter allows applications coded to the Log4j 2 API to be routed to SLF4J. +Use of this adapter may cause some loss of performance as the Log4j 2 Messages must be formatted +before they can be passed to SLF4J. With Log4j 2 as the implementation these would normally be +formatted only when they are accessed by a Filter or Appender. + +## Requirements + +The Log4j 2 to SLF4J adapter is dependent on the Log4j 2 API and the SLF4J API. +For more information, see [Runtime Dependencies](../runtime-dependencies.html). + +## Usage + +Include this jar, the SLF4J jar(s) and an SLF4J logging implementation jar together. Configure +the logging implementation as required. + +
+Use of the SLF4J adapter (log4j-to-slf4j-2.x.jar) together with +the SLF4J bridge (log4j-slf4j-impl-2.x.jar) should +never be attempted as it will cause events to endlessly be routed between +SLF4J and Log4j 2. +
diff --git a/log4j-to-slf4j/src/site/xdoc/index.xml b/log4j-to-slf4j/src/site/xdoc/index.xml deleted file mode 100644 index 13bbcc9..0000000 --- a/log4j-to-slf4j/src/site/xdoc/index.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - Log4j to SLF4J Adapter - Ralph Goers - - - -
- -

- The Log4j 2 to SLF4J Adapter allows applications coded to the Log4j 2 API to be routed to SLF4J. - Use of this adapter may cause some loss of performance as the Log4j 2 Messages must be formatted - before they can be passed to SLF4J. With Log4j 2 as the implementation these would normally be - formatted only when they are accessed by a Filter or Appender. -

- -
- -
-

- The Log4j 2 to SLF4J adapter is dependent on the Log4j 2 API and the SLF4J API. - For more information, see Runtime Dependencies. -

-
- -
-

- Include this jar, the SLF4J jar(s) and an SLF4J logging implementation jar together. Configure - the logging implementation as required. -

-

- Use of the SLF4J adapter (log4j-to-slf4j-2.x.jar) together with - the SLF4J bridge (log4j-slf4j-impl-2.x.jar) should - never be attempted as it will cause events to endlessly be routed between - SLF4J and Log4j 2. -

-
- - -
From 6dfe73b2df2171b3e57ecd4a0dd82afc31e6b043 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 26 Feb 2017 16:52:39 -0700 Subject: [PATCH 216/363] [maven-release-plugin] prepare release log4j-2.8.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5352d85..a51bde8 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.8.1-SNAPSHOT + 2.8.1 ../ log4j-to-slf4j From 2b97f5ee3938e15aa8a5237bb5f9bd16a2c81b85 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 26 Feb 2017 16:52:57 -0700 Subject: [PATCH 217/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index a51bde8..1e87e29 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.8.1 + 2.8.2-SNAPSHOT ../ log4j-to-slf4j From 7434fa6fa66064b8a6b57a3e7485d81e03b02f65 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 3 Mar 2017 12:35:24 -0700 Subject: [PATCH 218/363] LOG4J2-1836 - Update the API version --- .../src/main/resources/META-INF/log4j-provider.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties b/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties index 72b3a0b..f213cc2 100644 --- a/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties +++ b/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties @@ -14,6 +14,6 @@ # limitations under the License. LoggerContextFactory = org.apache.logging.slf4j.SLF4JLoggerContextFactory -Log4jAPIVersion = 2.0.0 +Log4jAPIVersion = 2.6.0 FactoryPriority= 15 ThreadContextMap = org.apache.logging.slf4j.MDCContextMap \ No newline at end of file From 6a8aee5a49de274b921017355372f406519c5011 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 2 Apr 2017 15:05:00 -0500 Subject: [PATCH 219/363] [maven-release-plugin] prepare release log4j-2.8.2-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 1e87e29..1f0e077 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.8.2-SNAPSHOT + 2.8.2 ../ log4j-to-slf4j From 72e47ea374f51d0f1906650b86786204a3b796d3 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 2 Apr 2017 15:05:16 -0500 Subject: [PATCH 220/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 1f0e077..ad28c3a 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.8.2 + 2.8.3-SNAPSHOT ../ log4j-to-slf4j From 5ce4ef300a6ac4315e5006a1750a5d5df9811e84 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 21 May 2017 01:27:57 -0700 Subject: [PATCH 221/363] LOG4J2-1917 - Use ServiceLoader to locate implementations. --- .../apache/logging/slf4j/SLF4JProvider.java | 28 +++++++++++++++++++ .../META-INF/log4j-provider.properties | 19 ------------- .../org.apache.logging.log4j.spi.Provider | 1 + 3 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java delete mode 100644 log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties create mode 100644 log4j-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider 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 new file mode 100644 index 0000000..979d5e9 --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java @@ -0,0 +1,28 @@ +/* + * 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.spi.Provider; + +/** + * Bind the Log4j API to SLF4J. + */ +public class SLF4JProvider extends Provider { + public SLF4JProvider() { + super(15, "2.6.0", SLF4JLoggerContextFactory.class, MDCContextMap.class); + } +} diff --git a/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties b/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties deleted file mode 100644 index f213cc2..0000000 --- a/log4j-to-slf4j/src/main/resources/META-INF/log4j-provider.properties +++ /dev/null @@ -1,19 +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. - -LoggerContextFactory = org.apache.logging.slf4j.SLF4JLoggerContextFactory -Log4jAPIVersion = 2.6.0 -FactoryPriority= 15 -ThreadContextMap = org.apache.logging.slf4j.MDCContextMap \ No newline at end of file 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 new file mode 100644 index 0000000..c66b5c9 --- /dev/null +++ b/log4j-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider @@ -0,0 +1 @@ +org.apache.logging.slf4j.SLF4JProvider \ No newline at end of file From f81cf2d02d3293f780fdb051c8f25bd5172b21aa Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 29 Jun 2017 14:14:13 -0700 Subject: [PATCH 222/363] Update POM versions from 2.8.3-SNAPSHOT to 2.9-SNAPSHOT. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ad28c3a..7a9f442 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.8.3-SNAPSHOT + 2.9-SNAPSHOT ../ log4j-to-slf4j From 92a05275ae443e0e09f57787ea845b2e707427b8 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sat, 26 Aug 2017 13:36:18 -0700 Subject: [PATCH 223/363] [maven-release-plugin] prepare release log4j-2.9-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7a9f442..13e1dd7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.9-SNAPSHOT + 2.9.0 ../ log4j-to-slf4j From 523c230e814d63c8ab3cfffb277ac9df61adfe04 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sat, 26 Aug 2017 13:36:35 -0700 Subject: [PATCH 224/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 13e1dd7..7610ce7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.9.0 + 2.9.1-SNAPSHOT ../ log4j-to-slf4j From 19c830bbdc8ee7a4e8470a4ac91abdb7adcc2517 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 17 Sep 2017 22:51:04 -0700 Subject: [PATCH 225/363] [maven-release-plugin] prepare release log4j-2.9.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7610ce7..97ba8ec 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.9.1-SNAPSHOT + 2.9.1 ../ log4j-to-slf4j From 0febc9bfd7965dff9989b68ad157b733abd891a8 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 17 Sep 2017 22:51:21 -0700 Subject: [PATCH 226/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 97ba8ec..b26fcf4 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.9.1 + 2.9.2-SNAPSHOT ../ log4j-to-slf4j From 366e4e7f1f3124c48ecba4748af4396ac1d8c68d Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 12 Oct 2017 17:08:51 -0600 Subject: [PATCH 227/363] The next version will be 2.10.0. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b26fcf4..ac3e30b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.9.2-SNAPSHOT + 2.10.0-SNAPSHOT ../ log4j-to-slf4j From e4a789ef182c26cfa33f88d3f09a0a619fff5f8d Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sat, 14 Oct 2017 22:34:09 -0700 Subject: [PATCH 228/363] LOG4J-2056 - modularize log4j-api. Turn others into automatic modules --- log4j-to-slf4j/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ac3e30b..cfd777c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -31,6 +31,7 @@ ${basedir}/.. SLF4J Documentation /log4j-to-slf4j + org.apache.logging.slf4j
From 73fc7628bec3c6e739603f9f869dee91463ca3f1 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 19 Nov 2017 00:47:36 -0700 Subject: [PATCH 229/363] [maven-release-plugin] prepare release log4j-2.10-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cfd777c..840d816 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.10.0-SNAPSHOT + 2.10.0 ../ log4j-to-slf4j From cd612f5a29caf03585b1060e23926170f9924e65 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 19 Nov 2017 00:47:55 -0700 Subject: [PATCH 230/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 840d816..c723100 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.10.0 + 2.10.1-SNAPSHOT ../ log4j-to-slf4j From 21c6ee216eb4e8fc40a6a9ab87922a00789d115f Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 1 Mar 2018 08:14:42 -0700 Subject: [PATCH 231/363] Update POMs from version 2.10.1-SNAPSHOT to 2.11.0-SNAPSHOT to stop some of the current confusion with JIRA marking the next release as 2.11.0. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c723100..b188232 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.10.1-SNAPSHOT + 2.11.0-SNAPSHOT ../ log4j-to-slf4j From 555c85743c5a9e71825e6b5a7a5d811370a9ceb2 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 11 Mar 2018 15:41:24 -0700 Subject: [PATCH 232/363] [maven-release-plugin] prepare release log4j-2.11.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b188232..e9b5050 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.0-SNAPSHOT + 2.11.0 ../ log4j-to-slf4j From b3c30ae5e5ce131c92ec5df92221b50f08ea63e6 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 11 Mar 2018 15:42:32 -0700 Subject: [PATCH 233/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index e9b5050..cb35cf4 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.0 + 2.11.1-SNAPSHOT ../ log4j-to-slf4j From b14a5252b39000e0e53b395d72571b9e956314bf Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 22 Jul 2018 19:55:36 -0700 Subject: [PATCH 234/363] [maven-release-plugin] prepare release log4j-2.11.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cb35cf4..8a7a151 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.1-SNAPSHOT + 2.11.1 ../ log4j-to-slf4j From cf6afd6d6e052703a7f598afe4ae56345e3223da Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 22 Jul 2018 19:55:54 -0700 Subject: [PATCH 235/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 8a7a151..42cc2ea 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.1 + 2.11.2-SNAPSHOT ../ log4j-to-slf4j From 8d32d8673db7f7dc26705bc6847ac5ade8ef00b5 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 22 Jul 2018 19:57:33 -0700 Subject: [PATCH 236/363] [maven-release-plugin] rollback the release of log4j-2.11.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 42cc2ea..cb35cf4 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.2-SNAPSHOT + 2.11.1-SNAPSHOT ../ log4j-to-slf4j From d020ec5e6703dd7d8ab54d1e65b27c954b694f9b Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 22 Jul 2018 20:43:06 -0700 Subject: [PATCH 237/363] [maven-release-plugin] prepare release log4j-2.11.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cb35cf4..8a7a151 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.1-SNAPSHOT + 2.11.1 ../ log4j-to-slf4j From ad069dee0be60a6d5bbe47113241abdfccd2d79a Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 22 Jul 2018 20:43:23 -0700 Subject: [PATCH 238/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 8a7a151..42cc2ea 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.1 + 2.11.2-SNAPSHOT ../ log4j-to-slf4j From 72ed89a2006f4b36c7a475bfa835f866031f9491 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 3 Feb 2019 13:00:42 -0700 Subject: [PATCH 239/363] [maven-release-plugin] prepare release log4j-2.11.2-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 42cc2ea..6c1ef98 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.2-SNAPSHOT + 2.11.2 ../ log4j-to-slf4j From e7cb2cf58976b4fe4369755576402ccbdb77720d Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 3 Feb 2019 13:03:26 -0700 Subject: [PATCH 240/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6c1ef98..7dc607c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.2 + 2.12.0-SNAPSHOT ../ log4j-to-slf4j From b177ccfba5b27afee1981e2df89f32460287929b Mon Sep 17 00:00:00 2001 From: rgoers Date: Mon, 4 Feb 2019 20:52:46 -0700 Subject: [PATCH 241/363] [maven-release-plugin] prepare release log4j-2.11.2-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7dc607c..6c1ef98 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.0-SNAPSHOT + 2.11.2 ../ log4j-to-slf4j From 7d7cab5f045ccba0911962120d08377718039690 Mon Sep 17 00:00:00 2001 From: rgoers Date: Mon, 4 Feb 2019 20:53:09 -0700 Subject: [PATCH 242/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6c1ef98..7dc607c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.2 + 2.12.0-SNAPSHOT ../ log4j-to-slf4j From 549311d7fefc5a291fa6e61e82686f82badc65ea Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 5 Feb 2019 18:10:08 -0700 Subject: [PATCH 243/363] [maven-release-plugin] prepare release log4j-2.11.2-rc3 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7dc607c..6c1ef98 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.0-SNAPSHOT + 2.11.2 ../ log4j-to-slf4j From 246b809537f6921038d8250b80c4ff8f202f9725 Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 5 Feb 2019 18:10:30 -0700 Subject: [PATCH 244/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6c1ef98..7dc607c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.11.2 + 2.12.0-SNAPSHOT ../ log4j-to-slf4j From 68c09b66316afd91aac342e8a3f95240e56c36ea Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 23 Jun 2019 16:22:02 -0700 Subject: [PATCH 245/363] [maven-release-plugin] prepare release log4j-2.12.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7dc607c..7097b61 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.0-SNAPSHOT + 2.12.0 ../ log4j-to-slf4j From ca573edddcb65130e8077fbc3440142ca9806f21 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 23 Jun 2019 16:22:25 -0700 Subject: [PATCH 246/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7097b61..6ed6c7e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.0 + 2.12.1-SNAPSHOT ../ log4j-to-slf4j From 124ddef0e8897fc0efa63af27c96c19f9b8fd2ee Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 23 Jun 2019 16:35:03 -0700 Subject: [PATCH 247/363] [maven-release-plugin] rollback the release of log4j-2.12.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6ed6c7e..7dc607c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.1-SNAPSHOT + 2.12.0-SNAPSHOT ../ log4j-to-slf4j From e148a913585672312dd6f42be40b24b4219d044f Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 23 Jun 2019 16:57:21 -0700 Subject: [PATCH 248/363] [maven-release-plugin] prepare release log4j-2.12.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7dc607c..7097b61 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.0-SNAPSHOT + 2.12.0 ../ log4j-to-slf4j From e2b6388a9796df0b3ab6d4917cc3db163e836f97 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 23 Jun 2019 16:57:42 -0700 Subject: [PATCH 249/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7097b61..6ed6c7e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.0 + 2.12.1-SNAPSHOT ../ log4j-to-slf4j From 4c3967ffdb79e5b9ff47e47548abfdea4d8f0f6a Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 25 Jun 2019 20:34:19 -0700 Subject: [PATCH 250/363] [maven-release-plugin] prepare release log4j-2.12.0-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6ed6c7e..7097b61 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.1-SNAPSHOT + 2.12.0 ../ log4j-to-slf4j From e6fdacdd61087aaaf87055df40c7f3c4ea6ee534 Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 25 Jun 2019 20:34:41 -0700 Subject: [PATCH 251/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7097b61..6ed6c7e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.0 + 2.12.1-SNAPSHOT ../ log4j-to-slf4j From 243bdadb7c3973b1e40c944152e3f21e0da92370 Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 6 Aug 2019 20:42:02 -0700 Subject: [PATCH 252/363] [maven-release-plugin] prepare release log4j-2.12.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6ed6c7e..3956ba1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.1-SNAPSHOT + 2.12.1 ../ log4j-to-slf4j From 1b29c81876caaff8212c36a376db68697f313f68 Mon Sep 17 00:00:00 2001 From: rgoers Date: Tue, 6 Aug 2019 20:42:27 -0700 Subject: [PATCH 253/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3956ba1..735b7d1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.12.1 + 2.13.0-SNAPSHOT ../ log4j-to-slf4j From 55cdc3260a8fe45d631dee0a07a05b864f15f4f2 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 8 Dec 2019 17:10:18 -0700 Subject: [PATCH 254/363] [maven-release-plugin] prepare release log4j-2.13.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 735b7d1..72aa6a9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.0-SNAPSHOT + 2.13.0 ../ log4j-to-slf4j From b03c81ba745b5bdf7f20ccfbece60db5af8b0c7b Mon Sep 17 00:00:00 2001 From: rgoers Date: Sun, 8 Dec 2019 17:10:43 -0700 Subject: [PATCH 255/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 72aa6a9..77e9ad8 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.0 + 2.13.1-SNAPSHOT ../ log4j-to-slf4j From 6819b24496573c4ed81e86f88b76c7ccd9957a3e Mon Sep 17 00:00:00 2001 From: rgoers Date: Wed, 11 Dec 2019 19:39:03 -0700 Subject: [PATCH 256/363] [maven-release-plugin] prepare release log4j-2.13.0-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 77e9ad8..72aa6a9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.1-SNAPSHOT + 2.13.0 ../ log4j-to-slf4j From 32ed7909bf6306df88ae72c56ef42cfd55f492f5 Mon Sep 17 00:00:00 2001 From: rgoers Date: Wed, 11 Dec 2019 19:39:28 -0700 Subject: [PATCH 257/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 72aa6a9..77e9ad8 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.0 + 2.13.1-SNAPSHOT ../ log4j-to-slf4j From 6cc5e6ac4f1407a5fc8b09a42d9265af6bf5aa2e Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 23 Feb 2020 20:23:52 -0700 Subject: [PATCH 258/363] [maven-release-plugin] prepare release log4j-2.13.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 77e9ad8..77a9e6e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.1-SNAPSHOT + 2.13.1 ../ log4j-to-slf4j From 1aebc91bbcad6742a3457d6a19c1f9b92773db79 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 23 Feb 2020 20:24:31 -0700 Subject: [PATCH 259/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 77a9e6e..a857b1c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.1 + 2.13.2-SNAPSHOT ../ log4j-to-slf4j From 2223c0e2736344d8823242707e80d4916bc7c707 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 24 Feb 2020 23:14:49 -0700 Subject: [PATCH 260/363] [maven-release-plugin] prepare release log4j-2.13.1-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index a857b1c..77a9e6e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.2-SNAPSHOT + 2.13.1 ../ log4j-to-slf4j From 7b85ba6e9890321415661d50fd9fccd84238f83e Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 24 Feb 2020 23:15:10 -0700 Subject: [PATCH 261/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 77a9e6e..a857b1c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.1 + 2.13.2-SNAPSHOT ../ log4j-to-slf4j From b32311b1d0ec20b7be872a37c6e7dbb2be0850c9 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 25 Feb 2020 19:52:07 -0700 Subject: [PATCH 262/363] [maven-release-plugin] prepare release log4j-2.13.1-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index a857b1c..77a9e6e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.2-SNAPSHOT + 2.13.1 ../ log4j-to-slf4j From 47940c82c5aca0bdda3198d3f73699d75d0840f6 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 25 Feb 2020 19:52:29 -0700 Subject: [PATCH 263/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 77a9e6e..a857b1c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.1 + 2.13.2-SNAPSHOT ../ log4j-to-slf4j From b9bd583dd292b600d55efef8b18b75b62a68ab3d Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 20 Apr 2020 21:36:16 -0700 Subject: [PATCH 264/363] [maven-release-plugin] prepare release log4j-2.13.2-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index a857b1c..617e5c9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.2-SNAPSHOT + 2.13.2 ../ log4j-to-slf4j From 08ae3560fc7b3b8ff7ffcfe2d83aa50a1d82a60b Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 20 Apr 2020 21:36:38 -0700 Subject: [PATCH 265/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 617e5c9..2f8ce47 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.2 + 2.14.0-SNAPSHOT ../ log4j-to-slf4j From 2837fae20ce8460b512078501d03c561f628bf8e Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 10 May 2020 12:07:01 -0700 Subject: [PATCH 266/363] [maven-release-plugin] prepare release log4j-2.13.3-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 2f8ce47..ae99bf1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.14.0-SNAPSHOT + 2.13.3 ../ log4j-to-slf4j From 70933a4b586ff42561ddb91b2e5c787ee69b5bc8 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Sun, 10 May 2020 12:07:24 -0700 Subject: [PATCH 267/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ae99bf1..4c2cdf8 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.13.3 + 2.14.0--SNAPSHOT ../ log4j-to-slf4j From f1e456f20d1744e3dddc150843755295f4dfaa21 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 13 May 2020 09:36:37 -0400 Subject: [PATCH 268/363] [LOG4J2-2844] Null pointer exception when no network interfaces are available. Also fix POM version from "2.14.0--SNAPSHOT" to "2.14.0-SNAPSHOT". --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 4c2cdf8..2f8ce47 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.14.0--SNAPSHOT + 2.14.0-SNAPSHOT ../ log4j-to-slf4j From 5f9e25c54898b2f4e4b44705f22f1fc198cdd37d Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 2 Aug 2020 15:01:34 -0500 Subject: [PATCH 269/363] [LOG4J2-2653] Add initial JUnit 5 support This adds JUnit 5 support to most of the modules. Unchanged modules either contain no tests or use JUnit 4 specific features that need some adjustments to run in the JUnit vintage engine. Backported from 3.x which includes several pom.xml modernizations as well. --- log4j-to-slf4j/pom.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 2f8ce47..b36c02a 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -61,7 +61,18 @@ junit junit - test + + + org.junit.vintage + junit-vintage-engine + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.jupiter + junit-jupiter-engine org.hamcrest From 0a02c55656ec9d9a03ac886619ae32d800fe314d Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 2 Aug 2020 17:07:59 -0500 Subject: [PATCH 270/363] [LOG4J2-2653] Simplify JUnit dependencies --- log4j-to-slf4j/pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b36c02a..c8f6528 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -58,18 +58,10 @@ logback-classic test - - junit - junit - org.junit.vintage junit-vintage-engine - - org.junit.jupiter - junit-jupiter-api - org.junit.jupiter junit-jupiter-engine From 57da60060abb28cb0cb55fd1d7d0f5aa51b2fed4 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 19 Sep 2020 14:47:47 -0500 Subject: [PATCH 271/363] Swap findbugs with spotbugs Signed-off-by: Matt Sicker --- log4j-to-slf4j/pom.xml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c8f6528..d15f982 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -154,16 +154,8 @@ - org.codehaus.mojo - findbugs-maven-plugin - ${findbugs.plugin.version} - - true - -Duser.language=en - Normal - Default - ${log4jParentDir}/findbugs-exclude-filter.xml - + com.github.spotbugs + spotbugs-maven-plugin org.apache.maven.plugins From 1e6313154955d4b2c3aa598eedb56a20d4b44cd9 Mon Sep 17 00:00:00 2001 From: "Constantin Hirsch (SemVox)" <63846074+SiegfriedTobias1@users.noreply.github.com> Date: Tue, 6 Oct 2020 16:34:38 +0200 Subject: [PATCH 272/363] LOG4J2-2939: Fix NPE in MDCContextMap (#430) Accomodate for the fact that MDC.getCopyOfContextMap() may return null --- .../apache/logging/slf4j/MDCContextMap.java | 6 ++- .../org/apache/logging/slf4j/LoggerTest.java | 41 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) 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 index f03ee54..b04d358 100644 --- 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 @@ -71,7 +71,8 @@ public void clear() { @Override public boolean containsKey(final String key) { - return MDC.getCopyOfContextMap().containsKey(key); + Map map = MDC.getCopyOfContextMap(); + return map != null && map.containsKey(key); } @Override @@ -88,7 +89,8 @@ public Map getImmutableMapOrNull() { @Override public boolean isEmpty() { - return MDC.getCopyOfContextMap().isEmpty(); + Map map = MDC.getCopyOfContextMap(); + return map == null || map.isEmpty(); } @Override 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 index 77b9c4e..1f14110 100644 --- 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 @@ -33,6 +33,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; +import org.slf4j.MDC; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; @@ -183,5 +184,43 @@ public void mdc() { 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 + } + } +} From b88d398338d7be35c03151718dfded696d68b2e2 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 3 Nov 2020 12:39:43 -0700 Subject: [PATCH 273/363] Only generate doap file in parent project --- log4j-to-slf4j/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index d15f982..52acc05 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -32,6 +32,7 @@ SLF4J Documentation /log4j-to-slf4j org.apache.logging.slf4j + true From df7c9f717111381786ac9d8b812934f1edde421c Mon Sep 17 00:00:00 2001 From: rgoers Date: Fri, 6 Nov 2020 14:01:50 -0700 Subject: [PATCH 274/363] [maven-release-plugin] prepare release log4j-2.14.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 52acc05..119af37 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.14.0-SNAPSHOT + 2.14.0 ../ log4j-to-slf4j From 7b67afa836e29ba55310edd8a973ee41fff23567 Mon Sep 17 00:00:00 2001 From: rgoers Date: Fri, 6 Nov 2020 14:02:03 -0700 Subject: [PATCH 275/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 119af37..b983db9 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.14.0 + 2.14.1-SNAPSHOT ../ log4j-to-slf4j From 91fffcf13f5f7f759d2c71bd4adfce19e0a44d5b Mon Sep 17 00:00:00 2001 From: rgoers Date: Sat, 6 Mar 2021 22:10:51 -0700 Subject: [PATCH 276/363] [maven-release-plugin] prepare release log4j-2.14.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b983db9..af24d40 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.14.1-SNAPSHOT + 2.14.1 ../ log4j-to-slf4j From b7858d6ab3600601281b25a25d4389133f39f7d4 Mon Sep 17 00:00:00 2001 From: rgoers Date: Sat, 6 Mar 2021 22:11:01 -0700 Subject: [PATCH 277/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index af24d40..968e5ce 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.14.1 + 2.15.0-SNAPSHOT ../ log4j-to-slf4j From a17bb3f337edcbbc3b6ffae3d9f321a91661f87c Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Tue, 16 Mar 2021 15:21:21 -0400 Subject: [PATCH 278/363] LOG4J2-2940: Context selectors are aware of ClassLoader dependency This allows LoggerContext lookups to avoid searching for the calling class to discover a classloader when the ContextSelector implementation is declared to be agnostic to the class loader. Custom LoggerContextFactory and ContextSelector implementations should be updated to override the new `isClassLoaderDependent` method. --- .../apache/logging/slf4j/SLF4JLoggerContextFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 index 2f20685..7de053a 100644 --- 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 @@ -28,7 +28,7 @@ */ public class SLF4JLoggerContextFactory implements LoggerContextFactory { private static final StatusLogger LOGGER = StatusLogger.getLogger(); - private static LoggerContext context = new SLF4JLoggerContext(); + private static final LoggerContext context = new SLF4JLoggerContext(); public SLF4JLoggerContextFactory() { // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured) @@ -60,4 +60,10 @@ public LoggerContext getContext(final String fqcn, final ClassLoader loader, fin @Override public void removeContext(final LoggerContext ignored) { } + + @Override + public boolean isClassLoaderDependent() { + // context is always used + return false; + } } From 706ade956fbc76df5cbdaf0b1d64637133469046 Mon Sep 17 00:00:00 2001 From: Volkan Yazici Date: Sun, 24 Oct 2021 21:32:47 +0200 Subject: [PATCH 279/363] Upgrade from hamcrest-all:1.3 to hamcrest:2.2. --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 968e5ce..732f93b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -69,7 +69,7 @@ org.hamcrest - hamcrest-all + hamcrest test From bfc6a616d41a6f1836e6ecb8d0397dd1358e1e34 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 Dec 2021 15:58:46 -0700 Subject: [PATCH 280/363] [maven-release-plugin] prepare release log4j-2.15.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 732f93b..9a5328b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.15.0-SNAPSHOT + 2.15.0 ../ log4j-to-slf4j From 8c9ad6a2959564306cc1ab77552e52db2d4ef2ee Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Mon, 6 Dec 2021 16:13:26 -0700 Subject: [PATCH 281/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 9a5328b..0aee7a4 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.15.0 + 2.15.1-SNAPSHOT ../ log4j-to-slf4j From 628a602dc04dfe2c2f6811a9ed7a6d83269e23ab Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Thu, 9 Dec 2021 11:24:32 -0700 Subject: [PATCH 282/363] [maven-release-plugin] prepare release log4j-2.15.0-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0aee7a4..9a5328b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.15.1-SNAPSHOT + 2.15.0 ../ log4j-to-slf4j From d9b6d8a3048a1d5de23a4965b78f5b249fd3bbab Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Thu, 9 Dec 2021 11:24:40 -0700 Subject: [PATCH 283/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 9a5328b..0aee7a4 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.15.0 + 2.15.1-SNAPSHOT ../ log4j-to-slf4j From d97f3a7539d0df2a5e9b015c6b07630220d73918 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 11 Dec 2021 20:56:33 -0600 Subject: [PATCH 284/363] [maven-release-plugin] prepare release log4j-2.15.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0aee7a4..b876191 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.15.1-SNAPSHOT + 2.15.1 ../ log4j-to-slf4j From e36a5313b2db4595d814e48c2b71f0d7014d5d7e Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sat, 11 Dec 2021 20:57:21 -0600 Subject: [PATCH 285/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b876191..d837f99 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.15.1 + 2.16.0-SNAPSHOT ../ log4j-to-slf4j From f59a7ab418cfca9385c78e69b9c228d5a33fde2d Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 12 Dec 2021 23:40:13 -0600 Subject: [PATCH 286/363] [maven-release-plugin] prepare release log4j-2.16.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index d837f99..41620c5 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.16.0-SNAPSHOT + 2.16.0 ../ log4j-to-slf4j From 700c8cbb363aa480bab5ce2de3efc5d1c1bcd5ea Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Sun, 12 Dec 2021 23:40:21 -0600 Subject: [PATCH 287/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 41620c5..84b88ba 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.16.0 + 2.17.0-SNAPSHOT ../ log4j-to-slf4j From 8f288a26016c599252d5ef3c441bb16e03aa1343 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Dec 2021 18:56:20 -0700 Subject: [PATCH 288/363] [maven-release-plugin] prepare release log4j-2.17.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 84b88ba..7531aaa 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.17.0-SNAPSHOT + 2.17.0 ../ log4j-to-slf4j From dc0ccf1a4967d6dddc0e4d2d3e421bf129ee6189 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Dec 2021 18:56:28 -0700 Subject: [PATCH 289/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7531aaa..26d0312 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.17.0 + 2.17.1-SNAPSHOT ../ log4j-to-slf4j From 723d38addb7825408c4d6d9a0fae7618a841ff37 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Thu, 23 Dec 2021 17:25:10 +0100 Subject: [PATCH 290/363] Remove empty JavaDoc in log4j-to-slf4j --- .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 3 --- .../main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 3 --- .../org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 3 --- .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 3 --- 4 files changed, 12 deletions(-) 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 index 33e40c1..5ea8b7b 100644 --- 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 @@ -25,9 +25,6 @@ import org.slf4j.MarkerFactory; import org.slf4j.spi.LocationAwareLogger; -/** - * - */ public class SLF4JLogger extends AbstractLogger { private static final long serialVersionUID = 1L; 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 index 4c0120b..dbdf01c 100644 --- 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 @@ -22,9 +22,6 @@ import org.apache.logging.log4j.spi.LoggerRegistry; import org.slf4j.LoggerFactory; -/** - * - */ public class SLF4JLoggerContext implements LoggerContext { private final LoggerRegistry loggerRegistry = new LoggerRegistry<>(); 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 index 7de053a..28372e7 100644 --- 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 @@ -23,9 +23,6 @@ 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(); 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 index 1f14110..04f7a8c 100644 --- 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 @@ -38,9 +38,6 @@ import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; -/** - * - */ public class LoggerTest { private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; From 00dec427186fc99b36d005a24606b599ac166825 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Thu, 23 Dec 2021 17:20:43 +0100 Subject: [PATCH 291/363] Fix MessageFactory support bug in SLF4JLoggerContext as well as a related typo in LoggerTest --- .../org/apache/logging/slf4j/SLF4JLoggerContext.java | 12 +++--------- .../java/org/apache/logging/slf4j/LoggerTest.java | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) 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 index dbdf01c..94c71b0 100644 --- 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 @@ -40,17 +40,11 @@ public ExtendedLogger getLogger(final String name) { @Override public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) { - // FIXME according to LOG4J2-1180, the below line should be: - // FIXME if (!loggerRegistry.hasLogger(name, messageFactory)) { - if (!loggerRegistry.hasLogger(name)) { - // FIXME: should be loggerRegistry.putIfAbsent(name, messageFactory, - loggerRegistry.putIfAbsent(name, null, + if (!loggerRegistry.hasLogger(name, messageFactory)) { + loggerRegistry.putIfAbsent(name, messageFactory, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name))); } - // FIXME should be return loggerRegistry.getLogger(name, messageFactory); - return loggerRegistry.getLogger(name); - - // TODO applying the above fixes causes (log4j-to-slf4j) LoggerTest to fail + return loggerRegistry.getLogger(name, messageFactory); } @Override 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 index 04f7a8c..9ba6463 100644 --- 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 @@ -122,7 +122,7 @@ public void getLogger_String_MessageFactoryMismatch() { @Test public void getLogger_String_MessageFactoryMismatchNull() { - final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull", + final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull", StringFormatterMessageFactory.INSTANCE, null); testLogger.debug("%,d", Integer.MAX_VALUE); assertThat(list.strList, hasSize(1)); @@ -134,7 +134,7 @@ private Logger testMessageFactoryMismatch(final String name, final MessageFactor assertThat(testLogger, is(notNullValue())); checkMessageFactory(messageFactory1, testLogger); final Logger testLogger2 = LogManager.getLogger(name, messageFactory2); - checkMessageFactory(messageFactory1, testLogger2); + checkMessageFactory(messageFactory2, testLogger2); return testLogger; } From 6fdac8a11b27e811eae665e036a9e8f02c9d9c97 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Sat, 25 Dec 2021 11:48:20 -0500 Subject: [PATCH 292/363] LOG4J2-3289: Fix log4j-to-slf4j re-interpolation of formatted message data --- .../org/apache/logging/slf4j/SLF4JLogger.java | 28 +++++++++------- .../org/apache/logging/slf4j/LoggerTest.java | 33 +++++++++++++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) 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 index 5ea8b7b..be1a15a 100644 --- 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 @@ -86,10 +86,13 @@ public org.slf4j.Logger getLogger() { return locationAwareLogger != null ? locationAwareLogger : logger; } - private org.slf4j.Marker getMarker(final Marker marker) { - if (marker == null) { - return null; - } + 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) { @@ -222,31 +225,32 @@ private boolean isEnabledFor(final Level level, final Marker marker) { @Override public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) { + org.slf4j.Marker slf4jMarker = getMarker(marker); + String formattedMessage = message.getFormattedMessage(); if (locationAwareLogger != null) { if (message instanceof LoggerNameAwareMessage) { ((LoggerNameAwareMessage) message).setLoggerName(getName()); } - locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), message.getFormattedMessage(), - message.getParameters(), t); + locationAwareLogger.log(slf4jMarker, fqcn, convertLevel(level), formattedMessage, null, t); } else { switch (level.getStandardLevel()) { case DEBUG : - logger.debug(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.debug(slf4jMarker, formattedMessage, t); break; case TRACE : - logger.trace(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.trace(slf4jMarker, formattedMessage, t); break; case INFO : - logger.info(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.info(slf4jMarker, formattedMessage, t); break; case WARN : - logger.warn(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.warn(slf4jMarker, formattedMessage, t); break; case ERROR : - logger.error(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.error(slf4jMarker, formattedMessage, t); break; default : - logger.error(getMarker(marker), message.getFormattedMessage(), message.getParameters(), t); + logger.error(slf4jMarker, formattedMessage, t); break; } } 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 index 9ba6463..0d9995c 100644 --- 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 @@ -17,6 +17,8 @@ */ package org.apache.logging.slf4j; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Proxy; import java.util.Date; import java.util.List; @@ -160,6 +162,37 @@ public void debugObject() { public void debugWithParms() { logger.debug("Hello, {}", "World"); assertThat(list.strList, hasSize(1)); + 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)); + String message = list.strList.get(0); + assertEquals("Hello, foo {} bar", message); + } + + @Test + public void paramIncludesSubstitutionMarker_nonLocationAware() { + final org.slf4j.Logger slf4jLogger = CTX.getLogger(); + 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)); + String message = list.strList.get(0); + assertEquals("Hello, foo {} bar", message); } @Test From b862fee7bc6976e309c005d98be71a9ecd98ee94 Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Mon, 27 Dec 2021 17:29:31 -0600 Subject: [PATCH 293/363] [maven-release-plugin] prepare release log4j-2.17.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 26d0312..ed4651a 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.17.1-SNAPSHOT + 2.17.1 ../ log4j-to-slf4j From f3c51dd30a2ff6c86bee6fced34ceea78c6320cf Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Mon, 27 Dec 2021 17:29:39 -0600 Subject: [PATCH 294/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ed4651a..edad09f 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.17.1 + 2.17.2-SNAPSHOT ../ log4j-to-slf4j From dbcfa1614ee02f1ad9c72900ce5da482da83849b Mon Sep 17 00:00:00 2001 From: Matt Sicker Date: Fri, 21 Jan 2022 21:39:48 -0600 Subject: [PATCH 295/363] Clean up pom.xml files - Remove invalid values - Disable doap and changes plugins in child modules - Use correct Fragment-Host in bundles implementing log4j-core plugins - Add OSGi service loader metadata for more bundles --- log4j-to-slf4j/pom.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index edad09f..250a3b7 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -21,7 +21,6 @@ org.apache.logging.log4j log4j 2.17.2-SNAPSHOT - ../ log4j-to-slf4j jar @@ -96,6 +95,12 @@ org.apache.logging.slf4j + + osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)" + + + osgi.serviceloader;osgi.serviceloader=org.apache.logging.log4j.spi.Provider + From 2afd6af1cf30c182839c59d896610765d6f0239e Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 23 Feb 2022 13:27:21 -0700 Subject: [PATCH 296/363] [maven-release-plugin] prepare release log4j-2.17.2-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 250a3b7..bb6fc4e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.17.2-SNAPSHOT + 2.17.2 log4j-to-slf4j jar From 493af8a402b1589dc62db78394ce77ed4ce9cc1d Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Wed, 23 Feb 2022 13:27:33 -0700 Subject: [PATCH 297/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index bb6fc4e..5ed42b6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.17.2 + 2.17.3-SNAPSHOT log4j-to-slf4j jar From 67b4b5e1bf99a82fb0c73035ca7159a602fde344 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 28 Jun 2022 15:02:52 -0700 Subject: [PATCH 298/363] [maven-release-plugin] prepare release log4j-2.18.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 5ed42b6..aadf4d1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.17.3-SNAPSHOT + 2.18.0 log4j-to-slf4j jar From 5e538eda73fd605cec040b9e71ac29c1a5566d26 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 28 Jun 2022 15:03:03 -0700 Subject: [PATCH 299/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index aadf4d1..7e96514 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.18.0 + 2.18.1-SNAPSHOT log4j-to-slf4j jar From 858d9e35a9b00bb96cf8bb13c097ed097e3f22bc Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sun, 3 Jul 2022 21:04:11 +0200 Subject: [PATCH 300/363] [LOG4J2-3546] Switch from `osgi.serviceloader` to `Activator` Switches `log4j-to-slf4j` and `log4j-to-jul` from using the Service Loader Mediator to registering their provider themselves. This way they can be used in minimal OSGI systems. Newer tests in `log4j-osgi` are written using PAX Exam in order to provide a larger OSGI environment. --- log4j-to-slf4j/pom.xml | 11 ++++---- .../org/apache/logging/slf4j/Activator.java | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7e96514..1750f50 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -42,6 +42,10 @@ org.apache.logging.log4j log4j-api + + org.osgi + org.osgi.core + ch.qos.logback logback-core @@ -94,13 +98,8 @@ maven-bundle-plugin + org.apache.logging.slf4j.Activator org.apache.logging.slf4j - - osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)" - - - osgi.serviceloader;osgi.serviceloader=org.apache.logging.log4j.spi.Provider - 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 new file mode 100644 index 0000000..fc997e5 --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java @@ -0,0 +1,28 @@ +/* + * 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; + +public class Activator extends ProviderActivator { + + public Activator() { + super(new SLF4JProvider()); + } + +} From c6e7cb5da8539211bbe9779ec991a4e4fd20e63d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Tue, 6 Sep 2022 14:37:30 +0200 Subject: [PATCH 301/363] Use `junit-bom` This replaces independent JUnit5 dependency versioning with a single `junit-bom` dependency. --- log4j-to-slf4j/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 1750f50..ca2bc26 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -65,10 +65,12 @@ org.junit.vintage junit-vintage-engine + test org.junit.jupiter junit-jupiter-engine + test org.hamcrest From 5f5241f0e98347ecb15fec176bf8e261756cb560 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 9 Sep 2022 00:18:17 -0700 Subject: [PATCH 302/363] [maven-release-plugin] prepare release log4j-2.19.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ca2bc26..c376e1a 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.18.1-SNAPSHOT + 2.19.0 log4j-to-slf4j jar From fb1d1fc3ae50e348a21bc4379a0c772e133bc8eb Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 9 Sep 2022 00:18:29 -0700 Subject: [PATCH 303/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c376e1a..0567898 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.0 + 2.19.1-SNAPSHOT log4j-to-slf4j jar From 52bec6c9406c8dac982b4894e002cbbdf5b83b7e Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 9 Sep 2022 12:24:00 -0700 Subject: [PATCH 304/363] [maven-release-plugin] prepare release log4j-2.19.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0567898..c376e1a 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.1-SNAPSHOT + 2.19.0 log4j-to-slf4j jar From faded462a15d7de4e35d5a7ed0b739728d4f9beb Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 9 Sep 2022 12:24:11 -0700 Subject: [PATCH 305/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c376e1a..0567898 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.0 + 2.19.1-SNAPSHOT log4j-to-slf4j jar From 9d9aac8a39d41122255012afa71ca61ba8488892 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 13 Sep 2022 10:15:41 -0700 Subject: [PATCH 306/363] [maven-release-plugin] prepare release log4j-2.19.0-rc2 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0567898..c376e1a 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.1-SNAPSHOT + 2.19.0 log4j-to-slf4j jar From 310cdd64e37609c010c409d15d9ca7e4fff9ce53 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Tue, 13 Sep 2022 10:15:54 -0700 Subject: [PATCH 307/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c376e1a..42a645b 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.0 + 2.29.1-SNAPSHOT log4j-to-slf4j jar From 61663c8ee660359b886372331d541f2db4e1a475 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sat, 17 Sep 2022 00:53:47 +0200 Subject: [PATCH 308/363] Fix new snapshot version --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 42a645b..0567898 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.29.1-SNAPSHOT + 2.19.1-SNAPSHOT log4j-to-slf4j jar From bacfd00067f84f9e909dbc1357d11411306c6917 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 16 Sep 2022 11:18:23 +0200 Subject: [PATCH 309/363] Add scopes to child POM dependencies This removes the scope of the dependencies from and adds it to the children POMs. The reason behind this is that we don't want to force the scope of transitive dependencies: e.g. `log4j-api` has a `javax.inject` transitive test dependency. If we set the scope to `provided` in the parent POM, the test dependency becomes a provided dependency. --- log4j-to-slf4j/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0567898..7199900 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -45,6 +45,7 @@ org.osgi org.osgi.core + provided ch.qos.logback From b22211eb9884e5318a8ec9d97b278217c6a1574b Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sun, 18 Sep 2022 20:24:48 +0200 Subject: [PATCH 310/363] Sort dependencies in POMs Improves the `src/tools/sort-pom.xslt` stylesheet to sort dependencies in the POM files according to the scope, artifact id (with a priority for Logj2 artifacts) and group id. It uses this script to automatically sort all POM files. --- log4j-to-slf4j/pom.xml | 69 +++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 7199900..fccb556 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -35,52 +35,62 @@ - org.slf4j - slf4j-api + org.osgi + org.osgi.core + provided org.apache.logging.log4j log4j-api - org.osgi - org.osgi.core - provided + org.slf4j + slf4j-api - ch.qos.logback - logback-core + org.hamcrest + hamcrest test - ch.qos.logback - logback-core - test-jar + org.junit.jupiter + junit-jupiter-engine test - ch.qos.logback - logback-classic + org.junit.vintage + junit-vintage-engine test - org.junit.vintage - junit-vintage-engine + ch.qos.logback + logback-classic test - org.junit.jupiter - junit-jupiter-engine + ch.qos.logback + logback-core test - org.hamcrest - hamcrest + ch.qos.logback + logback-core + test-jar test + + org.apache.felix + maven-bundle-plugin + + + org.apache.logging.slf4j.Activator + org.apache.logging.slf4j + + + org.apache.maven.plugins @@ -96,16 +106,6 @@ - - org.apache.felix - maven-bundle-plugin - - - org.apache.logging.slf4j.Activator - org.apache.logging.slf4j - - - @@ -144,9 +144,9 @@ maven-javadoc-plugin ${javadoc.plugin.version} - Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.
+ <p align="center">Copyright &#169; {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br /> Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, - and the Apache Log4j logo are trademarks of The Apache Software Foundation.

]]>
+ and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p>
false @@ -161,10 +161,6 @@ - - com.github.spotbugs - spotbugs-maven-plugin - org.apache.maven.plugins maven-jxr-plugin @@ -192,7 +188,10 @@ ${maven.compiler.target}
+ + com.github.spotbugs + spotbugs-maven-plugin +
- From 066c1bc7fb7dfcafc37d5790a68173c18c9310b8 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sun, 18 Sep 2022 10:53:36 +0200 Subject: [PATCH 311/363] Delegates plugin versions to ASF parent This PR removes all explicitly versioned plugins that are also defined in the Apache ASF parent POM (`org.apache:apache`). This has the following effect on plugin versions: * `maven-assembly-plugin` bumped to 3.4.1 * `maven-jar-plugin` bumped to 3.2.2 * `maven-javadoc-plugin` bumped to 3.4.0 * `maven-project-info-reports-plugin` bumped to 3.3.0 * `maven-release-plugin` bumped to 3.0.0-M6 * `maven-scm-plugin` bumped to 1.13.0 * `maven-site-plugin` bumped to 3.12.0 --- log4j-to-slf4j/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fccb556..22d6346 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -142,7 +142,6 @@ org.apache.maven.plugins maven-javadoc-plugin - ${javadoc.plugin.version} <p align="center">Copyright &#169; {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br /> Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, From d718c0e0845003b331eba32ffc729fb29ea2de22 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sun, 2 Oct 2022 08:32:58 +0200 Subject: [PATCH 312/363] Centralize plugin versions in main POM The versions of all used plugins are specified in the `log4j` parent POM or other parent POMs (`log4j-bom`, `log4j-samples`, `log4j-spring-cloud-config` or `log4j-spring-cloud-config-samples`). The script `src/tools/explicit-version.xslt` can be used to check for explicitly provided version. --- log4j-to-slf4j/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 22d6346..c97b6dd 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -113,7 +113,6 @@ org.apache.maven.plugins maven-changes-plugin - ${changes.plugin.version} @@ -129,7 +128,6 @@ org.apache.maven.plugins maven-checkstyle-plugin - ${checkstyle.plugin.version} ${log4jParentDir}/checkstyle.xml @@ -163,7 +161,6 @@ org.apache.maven.plugins maven-jxr-plugin - ${jxr.plugin.version} non-aggregate @@ -182,7 +179,6 @@ org.apache.maven.plugins maven-pmd-plugin - ${pmd.plugin.version} ${maven.compiler.target} From ac29f481d8fe7fbdb7d286b3d7eb2c4797ef3fd4 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Tue, 18 Oct 2022 11:01:39 +0200 Subject: [PATCH 313/363] Remove no-op plugin execution The 'default' maven-remote-resources-plugin execution is a no-op, because the ASF parent uses a different id. --- log4j-to-slf4j/pom.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c97b6dd..0294eb6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -91,21 +91,6 @@ - - - org.apache.maven.plugins - maven-remote-resources-plugin - - - - process - - - false - - - - From 2c72e6663bb21865956ce1bbb53d4dc331a22a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Fri, 13 Jan 2023 17:14:26 +0100 Subject: [PATCH 314/363] LOG4J2-3628 Replace `maven-changes-plugin` with `log4j-changelog` (#1145) --- log4j-to-slf4j/pom.xml | 15 --------------- log4j-to-slf4j/src/site/site.xml | 2 -- 2 files changed, 17 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0294eb6..b6c87fe 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -95,21 +95,6 @@ - - org.apache.maven.plugins - maven-changes-plugin - - - - changes-report - - - - - %URL%/show_bug.cgi?id=%ISSUE% - true - - org.apache.maven.plugins maven-checkstyle-plugin diff --git a/log4j-to-slf4j/src/site/site.xml b/log4j-to-slf4j/src/site/site.xml index 0f2364e..7715af4 100644 --- a/log4j-to-slf4j/src/site/site.xml +++ b/log4j-to-slf4j/src/site/site.xml @@ -43,8 +43,6 @@
- - From e93e0336ce9a297e2c070c6b5ffcfde7053617d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Mon, 16 Jan 2023 19:37:49 +0100 Subject: [PATCH 315/363] Simplify site generation (#1166) --- log4j-to-slf4j/pom.xml | 1 - log4j-to-slf4j/src/site/markdown/index.md | 41 ------------------- log4j-to-slf4j/src/site/site.xml | 50 ----------------------- 3 files changed, 92 deletions(-) delete mode 100644 log4j-to-slf4j/src/site/markdown/index.md delete mode 100644 log4j-to-slf4j/src/site/site.xml diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b6c87fe..ee49f44 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -31,7 +31,6 @@ SLF4J Documentation /log4j-to-slf4j org.apache.logging.slf4j - true diff --git a/log4j-to-slf4j/src/site/markdown/index.md b/log4j-to-slf4j/src/site/markdown/index.md deleted file mode 100644 index 34027e7..0000000 --- a/log4j-to-slf4j/src/site/markdown/index.md +++ /dev/null @@ -1,41 +0,0 @@ - - - -# Log4j to SLF4J Adapter - -The Log4j 2 to SLF4J Adapter allows applications coded to the Log4j 2 API to be routed to SLF4J. -Use of this adapter may cause some loss of performance as the Log4j 2 Messages must be formatted -before they can be passed to SLF4J. With Log4j 2 as the implementation these would normally be -formatted only when they are accessed by a Filter or Appender. - -## Requirements - -The Log4j 2 to SLF4J adapter is dependent on the Log4j 2 API and the SLF4J API. -For more information, see [Runtime Dependencies](../runtime-dependencies.html). - -## Usage - -Include this jar, the SLF4J jar(s) and an SLF4J logging implementation jar together. Configure -the logging implementation as required. - -
-Use of the SLF4J adapter (log4j-to-slf4j-2.x.jar) together with -the SLF4J bridge (log4j-slf4j-impl-2.x.jar) should -never be attempted as it will cause events to endlessly be routed between -SLF4J and Log4j 2. -
diff --git a/log4j-to-slf4j/src/site/site.xml b/log4j-to-slf4j/src/site/site.xml deleted file mode 100644 index 7715af4..0000000 --- a/log4j-to-slf4j/src/site/site.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 34aa863417290ffd531c5c9a2721e7ee88396d2d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 13 Jan 2023 06:15:27 +0100 Subject: [PATCH 316/363] [LOG4J2-3647] Add global filter support to `LogBuilder` `LogBuilder` suppliers in the `Logger` class always return a no-op builder if the log message level is higher than the configured level. This way global filters are always skipped. This patch always returns a functional builder if we detect the presence of a global filter. --- log4j-to-slf4j/pom.xml | 10 ++ .../apache/logging/slf4j/SLF4JLogBuilder.java | 128 ++++++++++++++++++ .../org/apache/logging/slf4j/SLF4JLogger.java | 56 ++++++++ .../apache/logging/slf4j/LogBuilderTest.java | 106 +++++++++++++++ .../src/test/resources/logback-slf4j.xml | 16 +++ .../test/resources/logback-turbofilter.xml | 39 ++++++ 6 files changed, 355 insertions(+) create mode 100644 log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java create mode 100644 log4j-to-slf4j/src/test/resources/logback-turbofilter.xml diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index ee49f44..6f741cc 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -46,6 +46,11 @@ org.slf4j slf4j-api + + org.assertj + assertj-core + test + org.hamcrest hamcrest @@ -56,6 +61,11 @@ junit-jupiter-engine test + + org.junit.jupiter + junit-jupiter-params + test + org.junit.vintage junit-vintage-engine 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 new file mode 100644 index 0000000..ad978fb --- /dev/null +++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java @@ -0,0 +1,128 @@ +/* + * 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.internal.DefaultLogBuilder; +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.spi.ExtendedLogger; + +public class SLF4JLogBuilder extends DefaultLogBuilder { + + public SLF4JLogBuilder(ExtendedLogger logger, Level level) { + super(logger, level); + } + + public SLF4JLogBuilder() { + super(); + } + + @Override + protected boolean isEnabled(Message message) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(CharSequence message) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object... params) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(Object message) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, + Object p6) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, + Object p6, Object p7) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, + Object p6, Object p7, Object p8) { + // SLF4J will check again later + return true; + } + + @Override + protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, + Object p6, Object p7, Object p8, Object p9) { + // SLF4J will check again later + return true; + } + +} 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 index be1a15a..ab1f839 100644 --- 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 @@ -17,17 +17,28 @@ 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 logBuilder = ThreadLocal.withInitial(SLF4JLogBuilder::new); + private final org.slf4j.Logger logger; private final LocationAwareLogger locationAwareLogger; @@ -256,4 +267,49 @@ public void logMessage(final String fqcn, final Level level, final Marker marker } } + @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(Level level) { + SLF4JLogBuilder builder = logBuilder.get(); + return Constants.ENABLE_THREADLOCALS && !builder.isInUse() ? builder.reset(this, level) + : new SLF4JLogBuilder(this, level); + } + + @Override + public LogBuilder atLevel(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/test/java/org/apache/logging/slf4j/LogBuilderTest.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java new file mode 100644 index 0000000..ec5ebfa --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java @@ -0,0 +1,106 @@ +/* + * 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.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.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; + +import static org.assertj.core.api.Assertions.assertThat; + +public class LogBuilderTest { + + private static final String CONFIG = "target/test-classes/logback-turbofilter.xml"; + 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"; + + private static LoggerContext context; + private static Logger logger; + private static StringListAppender list; + + @BeforeAll + public static void setUp() throws Exception { + context = (LoggerContext) LoggerFactory.getILoggerFactory(); + final JoranConfigurator configurator = new JoranConfigurator(); + configurator.setContext(context); + configurator.doConfigure(CONFIG); + + 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> 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(Consumer consumer) { + consumer.accept(logger.atTrace()); + try (Instance c = CloseableThreadContext.put("callerId", "Log4j2")) { + consumer.accept(logger.atTrace()); + assertThat(list.strList).hasSize(1); + } + list.strList.clear(); + } + + @ParameterizedTest + @MethodSource("logBuilderMethods") + void testLevelThreshold(Consumer consumer) { + consumer.accept(logger.atInfo()); + assertThat(list.strList).hasSize(1); + list.strList.clear(); + } +} diff --git a/log4j-to-slf4j/src/test/resources/logback-slf4j.xml b/log4j-to-slf4j/src/test/resources/logback-slf4j.xml index ad45676..8ade96b 100644 --- a/log4j-to-slf4j/src/test/resources/logback-slf4j.xml +++ b/log4j-to-slf4j/src/test/resources/logback-slf4j.xml @@ -1,4 +1,20 @@ + diff --git a/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml b/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml new file mode 100644 index 0000000..7b63422 --- /dev/null +++ b/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml @@ -0,0 +1,39 @@ + + + + + + ACCEPT + callerId + INFO + + Log4j2 + TRACE + + + + + + %msg + + + + + + + From 6182dae0325d5484884dbf303f5afabcfa397fd9 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sat, 14 Jan 2023 15:09:35 +0100 Subject: [PATCH 317/363] [LOG4J2-3647] Fix `log4j-to-slf4j` dependency on internal package Reimplements the log builder used in `log4j-to-slf4j` so that it does not depend on an internal `log4j-api` package. --- .../apache/logging/slf4j/SLF4JLogBuilder.java | 229 +++++++++++++----- .../org/apache/logging/slf4j/SLF4JLogger.java | 5 + 2 files changed, 180 insertions(+), 54 deletions(-) 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 index ad978fb..a910694 100644 --- 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 @@ -17,112 +17,233 @@ package org.apache.logging.slf4j; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.internal.DefaultLogBuilder; +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 extends DefaultLogBuilder { +public class SLF4JLogBuilder implements LogBuilder { - public SLF4JLogBuilder(ExtendedLogger logger, Level level) { - super(logger, level); + 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(SLF4JLogger logger, Level level) { + this.logger = logger; + this.level = level; + this.threadId = Thread.currentThread().getId(); + this.inUse = level != null; } public SLF4JLogBuilder() { - super(); + this(null, null); } - @Override - protected boolean isEnabled(Message message) { - // SLF4J will check again later + public LogBuilder reset(SLF4JLogger logger, 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 - protected boolean isEnabled(CharSequence message) { - // SLF4J will check again later - return true; + public LogBuilder withMarker(Marker marker) { + this.marker = marker; + return this; } @Override - protected boolean isEnabled(String message) { - // SLF4J will check again later - return true; + public LogBuilder withThrowable(Throwable throwable) { + this.throwable = throwable; + return this; } @Override - protected boolean isEnabled(String message, Object... params) { - // SLF4J will check again later - return true; + public LogBuilder withLocation() { + LOGGER.info("Call to withLocation() ignored since SLF4J does not support setting location information."); + return this; } @Override - protected boolean isEnabled(Object message) { - // SLF4J will check again later - return true; + public LogBuilder withLocation(StackTraceElement location) { + return withLocation(); } @Override - protected boolean isEnabled(String message, Object p0) { - // SLF4J will check again later - return true; + public void log(CharSequence message) { + if (isValid()) { + logMessage(logger.getMessageFactory().newMessage(message)); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1) { - // SLF4J will check again later - return true; + public void log(String message) { + if (isValid()) { + logMessage(logger.getMessageFactory().newMessage(message)); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2) { - // SLF4J will check again later - return true; + public void log(String message, Object... params) { + if (isValid()) { + logMessage(logger.getMessageFactory().newMessage(message, params)); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3) { - // SLF4J will check again later - return true; + public void log(String message, Supplier... params) { + if (isValid()) { + logMessage(logger.getMessageFactory().newMessage(message, LambdaUtil.getAll(params))); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4) { - // SLF4J will check again later - return true; + public void log(Message message) { + if (isValid()) { + logMessage(message); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) { - // SLF4J will check again later - return true; + public void log(Supplier messageSupplier) { + if (isValid()) { + logMessage(messageSupplier.get()); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, - Object p6) { - // SLF4J will check again later - return true; + public Message logAndGet(Supplier messageSupplier) { + Message message = null; + if (isValid()) { + logMessage(message = messageSupplier.get()); + } + return message; } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, - Object p6, Object p7) { - // SLF4J will check again later - return true; + public void log(Object message) { + if (isValid()) { + logMessage(logger.getMessageFactory().newMessage(message)); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, - Object p6, Object p7, Object p8) { - // SLF4J will check again later - return true; + public void log(String message, Object p0) { + if (isValid()) { + logMessage(logger.getMessageFactory().newMessage(message, p0)); + } } @Override - protected boolean isEnabled(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, - Object p6, Object p7, Object p8, Object p9) { - // SLF4J will check again later - return true; + 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 index ab1f839..553b0eb 100644 --- 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 @@ -267,6 +267,11 @@ public void logMessage(final String fqcn, final Level level, final Marker marker } } + @Override + public LogBuilder always() { + return atLevel(Level.OFF); + } + @Override public LogBuilder atTrace() { return atLevel(Level.TRACE); From d46a23a2c9fbf092a2d5b36240aeebcc2c22f482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Sun, 12 Feb 2023 21:53:05 +0100 Subject: [PATCH 318/363] Fix Javadoc generation and links for the site - Removed `maven-jxr-plugin` - Generating no Javadoc JARs (this was already the case) - Removed Javadoc JARs from the assembly in `log4j-distribution` - Generating Javadoc HTML only for `log4j-core` and `log4j-api` - Copying generated Javadoc HTML to `target/site/javadoc/` --- log4j-to-slf4j/pom.xml | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6f741cc..98502d0 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -116,45 +116,6 @@ licensedir=${log4jParentDir}/checkstyle-header.txt - - org.apache.maven.plugins - maven-javadoc-plugin - - <p align="center">Copyright &#169; {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br /> - Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, - and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p> - - false - true - - - - non-aggregate - - javadoc - - - - - - org.apache.maven.plugins - maven-jxr-plugin - - - non-aggregate - - jxr - - - - aggregate - - aggregate - - - - org.apache.maven.plugins maven-pmd-plugin From 3dbf2750a957fd132415948b09b08fa6f9b96992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Tue, 14 Feb 2023 21:10:18 +0100 Subject: [PATCH 319/363] Remove Maven `` blocks, since reporting is disabled --- log4j-to-slf4j/pom.xml | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 98502d0..4779cf2 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -102,31 +102,4 @@ - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - ${log4jParentDir}/checkstyle.xml - ${log4jParentDir}/checkstyle-suppressions.xml - false - basedir=${basedir} - licensedir=${log4jParentDir}/checkstyle-header.txt - - - - org.apache.maven.plugins - maven-pmd-plugin - - ${maven.compiler.target} - - - - com.github.spotbugs - spotbugs-maven-plugin - - - From 52366ac85ca5214c965f468ac97a5e517e37b729 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 18:26:33 -0700 Subject: [PATCH 320/363] [maven-release-plugin] prepare release log4j-2.20.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 4779cf2..bffa9a1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.1-SNAPSHOT + 2.20.0 log4j-to-slf4j jar From 310549396266b29b7d3b21ce204ace157cdd30ef Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 18:26:37 -0700 Subject: [PATCH 321/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index bffa9a1..3e2f225 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.20.0 + 2.20.1-SNAPSHOT log4j-to-slf4j jar From 7e188e0864e9cc8f038aae6eb95411979e5b9f5e Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 21:40:16 -0700 Subject: [PATCH 322/363] [maven-release-plugin] prepare release log4j-2.20.1-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3e2f225..bffa9a1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.20.1-SNAPSHOT + 2.20.0 log4j-to-slf4j jar From da43365641fdd7aca3d1750cc8c7341c4e13f200 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 21:48:49 -0700 Subject: [PATCH 323/363] Revert version update --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index bffa9a1..4779cf2 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.20.0 + 2.19.1-SNAPSHOT log4j-to-slf4j jar From dd58b2347cbf87332cfb061bf581fbd223779dbe Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 21:54:33 -0700 Subject: [PATCH 324/363] [maven-release-plugin] prepare release log4j-2.20.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 4779cf2..bffa9a1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.1-SNAPSHOT + 2.20.0 log4j-to-slf4j jar From e3844f1a96de7945034567027bfb581a9f74b040 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 21:54:36 -0700 Subject: [PATCH 325/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index bffa9a1..3e2f225 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.20.0 + 2.20.1-SNAPSHOT log4j-to-slf4j jar From 30653ded1909c0a36dd80e54ff45b316955833be Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 22:00:23 -0700 Subject: [PATCH 326/363] [maven-release-plugin] rollback the release of log4j-2.20.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3e2f225..4779cf2 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.20.1-SNAPSHOT + 2.19.1-SNAPSHOT log4j-to-slf4j jar From 8b3560b9c466d2e26d33a95dc96a3889acb4d551 Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 22:19:34 -0700 Subject: [PATCH 327/363] [maven-release-plugin] prepare release log4j-2.20.0-rc1 --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 4779cf2..bffa9a1 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.19.1-SNAPSHOT + 2.20.0 log4j-to-slf4j jar From e9c7836d14fbe68637e014ba4266d3be675e57aa Mon Sep 17 00:00:00 2001 From: Ralph Goers Date: Fri, 17 Feb 2023 22:19:38 -0700 Subject: [PATCH 328/363] [maven-release-plugin] prepare for next development iteration --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index bffa9a1..3e2f225 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.20.0 + 2.20.1-SNAPSHOT log4j-to-slf4j jar From 8fc740caca0a40ac2086c1b0635261cd5b3e9b3a Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Thu, 16 Mar 2023 15:34:26 +0100 Subject: [PATCH 329/363] [log4j-to-slf4j] Adapt OSGi metadata to work with slf4j 1 and 2 Use the version range [1.7,3) for the imported slf4j packages. See also https://bnd.bndtools.org/macros/range.html Fixes https://github.com/apache/logging-log4j2/issues/1232 Signed-off-by: Hannes Wellmann --- log4j-to-slf4j/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 3e2f225..851840c 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -31,6 +31,7 @@ SLF4J Documentation /log4j-to-slf4j org.apache.logging.slf4j + 3 @@ -97,6 +98,7 @@ org.apache.logging.slf4j.Activator org.apache.logging.slf4j + org.slf4j*;version="${range;[==,${slf4j.support.bound})}",* From 3a141b8bd419c7411ac2ad17b7014a69ab545f2c Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 29 Mar 2023 17:58:11 +0200 Subject: [PATCH 330/363] Renormalize Java file line endings This also runs `spotless:apply` on the modified files. --- .../slf4j/SLF4JLoggerContextFactory.java | 132 ++++++++-------- .../logging/slf4j/CallerInformationTest.java | 131 ++++++++-------- .../logging/slf4j/LoggerContextRule.java | 145 +++++++++--------- 3 files changed, 205 insertions(+), 203 deletions(-) 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 index 28372e7..aaa9dd0 100644 --- 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 @@ -1,66 +1,66 @@ -/* - * 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; - } -} +/* + * 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/test/java/org/apache/logging/slf4j/CallerInformationTest.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java index 7ebab7a..d8ed79b 100644 --- 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 @@ -1,65 +1,66 @@ -/* - * 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 ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.testUtil.StringListAppender; -import org.apache.logging.log4j.LogManager; -import org.junit.ClassRule; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class CallerInformationTest { - - private static final String CONFIG = "target/test-classes/logback-calling-class.xml"; - - @ClassRule - public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); - - @Test - public void testClassLogger() throws Exception { - final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger"); - final StringListAppender 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 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 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 messages = app.strList; - assertEquals("Incorrect number of messages.", 5, messages.size()); - for (final String message : messages) { - assertEquals("Incorrect caller method name.", "testMethodLogger", message); - } - } -} +/* + * 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.LogManager; +import org.junit.ClassRule; +import org.junit.Test; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; + +import static org.junit.Assert.*; + +public class CallerInformationTest { + + private static final String CONFIG = "target/test-classes/logback-calling-class.xml"; + + @ClassRule + public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); + + @Test + public void testClassLogger() throws Exception { + final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger"); + final StringListAppender 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 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 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 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/LoggerContextRule.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java index 0f245e2..706ddc5 100644 --- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java @@ -1,72 +1,73 @@ -/* - * 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.GenericConfigurator; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.slf4j.LoggerFactory; - -/** - * JUnit {@link TestRule} similar to the TestRule in {@code log4j-core} of the same name. - * - * @since 2.1 - * @since 2.4.1 Renamed InitialLoggerContext to LoggerContextRule - */ -public class LoggerContextRule implements TestRule { - - private final String configLocation; - - private LoggerContext context; - - private String testClassName; - - public LoggerContextRule(final String configLocation) { - this.configLocation = configLocation; - } - - @Override - public Statement apply(final Statement base, final Description description) { - testClassName = description.getClassName(); - return new Statement() { - @Override - public void evaluate() throws Throwable { - context = (LoggerContext) LoggerFactory.getILoggerFactory(); - final GenericConfigurator configurator = new JoranConfigurator(); - configurator.setContext(context); - configurator.doConfigure(configLocation); - base.evaluate(); - } - }; - } - - public LoggerContext getContext() { - return context; - } - - public Logger getLogger() { - return context.getLogger(testClassName); - } - - public Logger getLogger(final String name) { - return context.getLogger(name); - } -} +/* + * 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.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.slf4j.LoggerFactory; + +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.GenericConfigurator; + +/** + * JUnit {@link TestRule} similar to the TestRule in {@code log4j-core} of the same name. + * + * @since 2.1 + * @since 2.4.1 Renamed InitialLoggerContext to LoggerContextRule + */ +public class LoggerContextRule implements TestRule { + + private final String configLocation; + + private LoggerContext context; + + private String testClassName; + + public LoggerContextRule(final String configLocation) { + this.configLocation = configLocation; + } + + @Override + public Statement apply(final Statement base, final Description description) { + testClassName = description.getClassName(); + return new Statement() { + @Override + public void evaluate() throws Throwable { + context = (LoggerContext) LoggerFactory.getILoggerFactory(); + final GenericConfigurator configurator = new JoranConfigurator(); + configurator.setContext(context); + configurator.doConfigure(configLocation); + base.evaluate(); + } + }; + } + + public LoggerContext getContext() { + return context; + } + + public Logger getLogger() { + return context.getLogger(testClassName); + } + + public Logger getLogger(final String name) { + return context.getLogger(name); + } +} From e522d69cc128531d8ebbe8e283f1966c7ae2a891 Mon Sep 17 00:00:00 2001 From: "spotless[bot]" Date: Tue, 25 Apr 2023 18:32:35 +0200 Subject: [PATCH 331/363] Apply Spotless to all files --- log4j-to-slf4j/pom.xml | 30 +++++++++--------- .../org/apache/logging/slf4j/Activator.java | 11 +++---- .../apache/logging/slf4j/MDCContextMap.java | 10 +++--- .../apache/logging/slf4j/SLF4JLogBuilder.java | 10 +++--- .../org/apache/logging/slf4j/SLF4JLogger.java | 10 +++--- .../logging/slf4j/SLF4JLoggerContext.java | 10 +++--- .../slf4j/SLF4JLoggerContextFactory.java | 10 +++--- .../apache/logging/slf4j/SLF4JProvider.java | 10 +++--- .../logging/slf4j/CallerInformationTest.java | 15 +++++---- .../logging/slf4j/Log4j2Jira1688Test.java | 11 +++---- .../apache/logging/slf4j/LogBuilderTest.java | 19 ++++++------ .../logging/slf4j/LoggerContextRule.java | 19 ++++++------ .../org/apache/logging/slf4j/LoggerTest.java | 31 +++++++++---------- .../org/apache/logging/slf4j/TestUtil.java | 10 +++--- .../test/resources/logback-calling-class.xml | 28 ++++++++--------- .../src/test/resources/logback-slf4j.xml | 28 ++++++++--------- .../test/resources/logback-turbofilter.xml | 28 ++++++++--------- 17 files changed, 142 insertions(+), 148 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 851840c..f47c2b3 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -1,20 +1,20 @@ + ~ 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. + --> 4.0.0 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 index fc997e5..53e6471 100644 --- 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 @@ -1,20 +1,19 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * 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; 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 index b04d358..8480ea8 100644 --- 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; 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 index a910694..e4c634d 100644 --- 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; 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 index 553b0eb..05e5f80 100644 --- 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; 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 index 94c71b0..5df3e43 100644 --- 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; 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 index aaa9dd0..530bc54 100644 --- 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; 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 index 979d5e9..802bf67 100644 --- 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; 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 index d8ed79b..d8c0f86 100644 --- 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 @@ -1,30 +1,29 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; import java.util.List; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; import org.apache.logging.log4j.LogManager; import org.junit.ClassRule; import org.junit.Test; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.testUtil.StringListAppender; - import static org.junit.Assert.*; public class CallerInformationTest { 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 index 7f4cc1c..dab6983 100644 --- 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 @@ -1,20 +1,19 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ - package org.apache.logging.slf4j; import java.util.Arrays; 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 index ec5ebfa..821acfc 100644 --- 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 @@ -1,24 +1,28 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; import java.util.function.Consumer; import java.util.stream.Stream; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.testUtil.StringListAppender; import org.apache.logging.log4j.CloseableThreadContext; import org.apache.logging.log4j.CloseableThreadContext.Instance; import org.apache.logging.log4j.LogBuilder; @@ -31,11 +35,6 @@ import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.LoggerFactory; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.joran.JoranConfigurator; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.testUtil.StringListAppender; - import static org.assertj.core.api.Assertions.assertThat; public class LogBuilderTest { diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java index 706ddc5..8697931 100644 --- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java @@ -1,30 +1,29 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.slf4j.LoggerFactory; - 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.GenericConfigurator; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.slf4j.LoggerFactory; /** * JUnit {@link TestRule} similar to the TestRule in {@code log4j-core} of the same name. 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 index 0d9995c..6cc6dcc 100644 --- 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 @@ -1,20 +1,19 @@ - /* -* 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. -*/ + * 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.reflect.InvocationTargetException; 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 index d69ffa9..591cc8e 100644 --- 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 @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * 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 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 + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.logging.slf4j; diff --git a/log4j-to-slf4j/src/test/resources/logback-calling-class.xml b/log4j-to-slf4j/src/test/resources/logback-calling-class.xml index 3251c7f..9cef52d 100644 --- a/log4j-to-slf4j/src/test/resources/logback-calling-class.xml +++ b/log4j-to-slf4j/src/test/resources/logback-calling-class.xml @@ -1,19 +1,19 @@ diff --git a/log4j-to-slf4j/src/test/resources/logback-slf4j.xml b/log4j-to-slf4j/src/test/resources/logback-slf4j.xml index 8ade96b..ec38ed6 100644 --- a/log4j-to-slf4j/src/test/resources/logback-slf4j.xml +++ b/log4j-to-slf4j/src/test/resources/logback-slf4j.xml @@ -1,19 +1,19 @@ diff --git a/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml b/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml index 7b63422..9305cc8 100644 --- a/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml +++ b/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml @@ -1,19 +1,19 @@ From e565fb0b4fcff8b1c3e12e0ff335783fc1af4a90 Mon Sep 17 00:00:00 2001 From: OpenRewrite Date: Sun, 4 Jun 2023 13:58:36 +0200 Subject: [PATCH 332/363] Use `final` whenever possible --- .../apache/logging/slf4j/MDCContextMap.java | 4 +-- .../apache/logging/slf4j/SLF4JLogBuilder.java | 14 ++++----- .../org/apache/logging/slf4j/SLF4JLogger.java | 10 +++---- .../apache/logging/slf4j/LogBuilderTest.java | 6 ++-- .../org/apache/logging/slf4j/LoggerTest.java | 30 +++++++++---------- 5 files changed, 32 insertions(+), 32 deletions(-) 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 index 8480ea8..dcf98cc 100644 --- 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 @@ -71,7 +71,7 @@ public void clear() { @Override public boolean containsKey(final String key) { - Map map = MDC.getCopyOfContextMap(); + final Map map = MDC.getCopyOfContextMap(); return map != null && map.containsKey(key); } @@ -89,7 +89,7 @@ public Map getImmutableMapOrNull() { @Override public boolean isEmpty() { - Map map = MDC.getCopyOfContextMap(); + final Map map = MDC.getCopyOfContextMap(); return map == null || map.isEmpty(); } 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 index e4c634d..042cfeb 100644 --- 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 @@ -41,7 +41,7 @@ public class SLF4JLogBuilder implements LogBuilder { private volatile boolean inUse; private final long threadId; - public SLF4JLogBuilder(SLF4JLogger logger, Level level) { + public SLF4JLogBuilder(final SLF4JLogger logger, final Level level) { this.logger = logger; this.level = level; this.threadId = Thread.currentThread().getId(); @@ -52,7 +52,7 @@ public SLF4JLogBuilder() { this(null, null); } - public LogBuilder reset(SLF4JLogger logger, Level level) { + public LogBuilder reset(final SLF4JLogger logger, final Level level) { this.logger = logger; this.level = level; this.marker = null; @@ -86,13 +86,13 @@ private void logMessage(Message message) { } @Override - public LogBuilder withMarker(Marker marker) { + public LogBuilder withMarker(final Marker marker) { this.marker = marker; return this; } @Override - public LogBuilder withThrowable(Throwable throwable) { + public LogBuilder withThrowable(final Throwable throwable) { this.throwable = throwable; return this; } @@ -104,7 +104,7 @@ public LogBuilder withLocation() { } @Override - public LogBuilder withLocation(StackTraceElement location) { + public LogBuilder withLocation(final StackTraceElement location) { return withLocation(); } @@ -144,14 +144,14 @@ public void log(Message message) { } @Override - public void log(Supplier messageSupplier) { + public void log(final Supplier messageSupplier) { if (isValid()) { logMessage(messageSupplier.get()); } } @Override - public Message logAndGet(Supplier messageSupplier) { + public Message logAndGet(final Supplier messageSupplier) { Message message = null; if (isValid()) { logMessage(message = messageSupplier.get()); 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 index 05e5f80..99a515b 100644 --- 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 @@ -236,8 +236,8 @@ private boolean isEnabledFor(final Level level, final Marker marker) { @Override public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) { - org.slf4j.Marker slf4jMarker = getMarker(marker); - String formattedMessage = message.getFormattedMessage(); + final org.slf4j.Marker slf4jMarker = getMarker(marker); + final String formattedMessage = message.getFormattedMessage(); if (locationAwareLogger != null) { if (message instanceof LoggerNameAwareMessage) { ((LoggerNameAwareMessage) message).setLoggerName(getName()); @@ -303,14 +303,14 @@ public LogBuilder atFatal() { } @Override - protected LogBuilder getLogBuilder(Level level) { - SLF4JLogBuilder builder = logBuilder.get(); + 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(Level level) { + public LogBuilder atLevel(final Level level) { // TODO: wrap SLF4J 2.x LoggingEventBuilder if (LAZY_LEVEL_CHECK) { return getLogBuilder(level); 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 index 821acfc..1cd7c35 100644 --- 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 @@ -86,9 +86,9 @@ static Stream> logBuilderMethods() { @ParameterizedTest @MethodSource("logBuilderMethods") - void testTurboFilter(Consumer consumer) { + void testTurboFilter(final Consumer consumer) { consumer.accept(logger.atTrace()); - try (Instance c = CloseableThreadContext.put("callerId", "Log4j2")) { + try (final Instance c = CloseableThreadContext.put("callerId", "Log4j2")) { consumer.accept(logger.atTrace()); assertThat(list.strList).hasSize(1); } @@ -97,7 +97,7 @@ void testTurboFilter(Consumer consumer) { @ParameterizedTest @MethodSource("logBuilderMethods") - void testLevelThreshold(Consumer consumer) { + void testLevelThreshold(final Consumer 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/LoggerTest.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java index 6cc6dcc..1b9e4b8 100644 --- 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 @@ -161,7 +161,7 @@ public void debugObject() { public void debugWithParms() { logger.debug("Hello, {}", "World"); assertThat(list.strList, hasSize(1)); - String message = list.strList.get(0); + final String message = list.strList.get(0); assertEquals("Hello, World", message); } @@ -169,28 +169,28 @@ public void debugWithParms() { public void paramIncludesSubstitutionMarker_locationAware() { logger.info("Hello, {}", "foo {} bar"); assertThat(list.strList, hasSize(1)); - String message = list.strList.get(0); + final String message = list.strList.get(0); assertEquals("Hello, foo {} bar", message); } @Test public void paramIncludesSubstitutionMarker_nonLocationAware() { final org.slf4j.Logger slf4jLogger = CTX.getLogger(); - 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(); - } - })); + 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)); - String message = list.strList.get(0); + final String message = list.strList.get(0); assertEquals("Hello, foo {} bar", message); } From 57a4ea4f84c2301bf5362bc35f0e20809e59531f Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 20 Sep 2023 09:04:34 +0200 Subject: [PATCH 333/363] Bump version to 2.21.0-SNAPSHOT --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index f47c2b3..d604599 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.20.1-SNAPSHOT + 2.21.0-SNAPSHOT log4j-to-slf4j jar From 033738984e7e80675f6fbba30c3049e8be4a152a Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Mon, 25 Sep 2023 10:57:24 +0200 Subject: [PATCH 334/363] Remove references to `maven-bundle-plugin` --- log4j-to-slf4j/pom.xml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index d604599..fdb6f76 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -89,19 +89,5 @@ test - - - - org.apache.felix - maven-bundle-plugin - - - org.apache.logging.slf4j.Activator - org.apache.logging.slf4j - org.slf4j*;version="${range;[==,${slf4j.support.bound})}",* - - - - - + From da8c568052e3e3d26876ef983f13536b128f8e4d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Tue, 26 Sep 2023 09:03:51 +0200 Subject: [PATCH 335/363] Replace explicit versions with property --- log4j-to-slf4j/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index fdb6f76..beca3ae 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -20,7 +20,7 @@ org.apache.logging.log4j log4j - 2.21.0-SNAPSHOT + ${revision} log4j-to-slf4j jar From 2c6d5d75e619fa815a76c74ef417dc20efb5243d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 29 Sep 2023 12:26:29 +0200 Subject: [PATCH 336/363] Add BND configuration to bridges --- log4j-to-slf4j/pom.xml | 9 ++++++++- .../java/org/apache/logging/slf4j/SLF4JProvider.java | 3 +++ .../main/java/org/apache/logging/slf4j/package-info.java | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index beca3ae..0a7f063 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -30,8 +30,15 @@ ${basedir}/.. SLF4J Documentation /log4j-to-slf4j - org.apache.logging.slf4j + + 3 + + + org.slf4j.*;version="${range;[==,${slf4j.support.bound})}" + 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 index 802bf67..b8514c4 100644 --- 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 @@ -16,11 +16,14 @@ */ package org.apache.logging.slf4j; +import aQute.bnd.annotation.Resolution; +import aQute.bnd.annotation.spi.ServiceProvider; import org.apache.logging.log4j.spi.Provider; /** * Bind the Log4j API to SLF4J. */ +@ServiceProvider(value = Provider.class, resolution = Resolution.OPTIONAL) public class SLF4JProvider extends Provider { public SLF4JProvider() { super(15, "2.6.0", SLF4JLoggerContextFactory.class, MDCContextMap.class); 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 index 092c09a..993db6c 100644 --- 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 @@ -17,4 +17,7 @@ /** * SLF4J support. */ +@Export package org.apache.logging.slf4j; + +import org.osgi.annotation.bundle.Export; From 3605ba749b43959c98f573ac2c48eb15f01aa067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Thu, 5 Oct 2023 09:51:52 +0200 Subject: [PATCH 337/363] Migrate changelog, site, and docs to the new infra --- log4j-to-slf4j/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 0a7f063..c5efcc6 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -27,7 +27,6 @@ Apache Log4j to SLF4J Adapter The Apache Log4j binding between Log4j 2 API and SLF4J. - ${basedir}/.. SLF4J Documentation /log4j-to-slf4j From 74b793f6820fc47c34bc7c988941a3faea64372d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Thu, 5 Oct 2023 12:45:34 +0200 Subject: [PATCH 338/363] Swap `/pom.xml` and `/log4j-bom/pom.xml` - `/pom.xml` is moved to `/log4j-parent/pom.xml` - `/log4j-bom/pom.xml` is moved to `/pom.xml` - Implements the BOM organization described by Maven[1]. That is, `parent` inherits from `bom`. - Takes advantage of `flatten-bom` provided by `logging-parent` - Identical scheme to the one found in `-tools` and `-transformation` [1] https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms --- log4j-to-slf4j/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index c5efcc6..b45ab40 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -21,6 +21,7 @@ org.apache.logging.log4j log4j ${revision} + ../log4j-parent log4j-to-slf4j jar From 38da3211cfbf554336111e8e8ee9416f3baadf0d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 6 Oct 2023 11:58:53 +0200 Subject: [PATCH 339/363] Remove `log4j-core` from some processor paths There are many modules that do not depend on `log4j-core` and they can be easily built without it on the processor path. --- log4j-to-slf4j/pom.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index b45ab40..75566d2 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -97,4 +97,22 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + com.google.errorprone + error_prone_core + ${error-prone.version} + + + + + + From 9c761180904e7ccb6ef3a9cb371e9fb397c06e39 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 6 Oct 2023 12:52:17 +0200 Subject: [PATCH 340/363] Add `log4j-core` to some modules processor path Since the split between modules that have Log4j Core plugins and those that don't is about 50/50, it is more proper to add `log4j-core` to some modules instead of removing it from others (and copy/paste all other options). --- log4j-to-slf4j/pom.xml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 75566d2..2ea30e8 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -96,23 +96,4 @@ test - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - com.google.errorprone - error_prone_core - ${error-prone.version} - - - - - - From 9e6c313859f3e0ce68228fb7899c0613b62a7873 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sun, 8 Oct 2023 07:31:46 +0200 Subject: [PATCH 341/363] Add OSGi package versioning and fix API breaking changes In order to prevent API breaking changes, this: * adds [`bnd-baseline-maven-plugin`](https://github.com/bndtools/bnd/tree/master/maven-plugins/bnd-baseline-maven-plugin), * fix the API changes that would require a major version bump, * set the OSGi version of each packages to `2.20.1` or `2.21.0`, depending on the kind of changes the package underwent since the `2.20.0` release. --- .../src/main/java/org/apache/logging/slf4j/package-info.java | 2 ++ 1 file changed, 2 insertions(+) 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 index 993db6c..e354601 100644 --- 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 @@ -18,6 +18,8 @@ * SLF4J support. */ @Export +@Version("2.20.1") package org.apache.logging.slf4j; import org.osgi.annotation.bundle.Export; +import org.osgi.annotation.versioning.Version; From c33f0fa0ab7d7bd4bb60e22d9ad01271633dad48 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 11 Oct 2023 19:40:18 +0200 Subject: [PATCH 342/363] Fix OSGi tests --- .../src/main/java/org/apache/logging/slf4j/Activator.java | 3 +++ 1 file changed, 3 insertions(+) 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 index 53e6471..aba66fc 100644 --- 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 @@ -17,7 +17,10 @@ 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() { From a0ff3e56e6c82f32c30d9134446a1d56104c9f9d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 20 Oct 2023 16:02:00 +0200 Subject: [PATCH 343/363] Ban dependencies interfering with our tests --- log4j-to-slf4j/pom.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 2ea30e8..cf5de79 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -96,4 +96,30 @@ test + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + ban-logging-dependencies + + + + + ch.qos.logback:*:*:*:test + + + + + + + + + From ec71ef73123635d27766529615636238641191fa Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Mon, 30 Oct 2023 11:21:52 +0100 Subject: [PATCH 344/363] Bump SLF4j to version 2.0.9 Most of our modules with a transitive dependency on `slf4j-api` used version 1.7.36, while `log4j-slf4j-impl` used version 1.7.25 (due to a breaking change in `slf4j-ext`) and `log4j-slf4j2-impl` used version 2.0.x. This PR simplifies this configuration by: * switching `log4j-slf4j-impl` to use version 1.7.36 of `slf4j-api` and version 1.7.25 of `slf4j-ext`, * removing the need of `slf4j-ext` where applicable, * switching all the other modules to SLF4J 2.x, * modernizing the `log4j-to-slf4j` tests to use JUnit 5 instead of JUnit 4. --- log4j-to-slf4j/pom.xml | 5 + .../logging/slf4j/CallerInformationTest.java | 11 +- .../logging/slf4j/Log4j2Jira1688Test.java | 10 +- .../apache/logging/slf4j/LogBuilderTest.java | 15 +- .../logging/slf4j/LoggerContextResolver.java | 165 ++++++++++++++++++ .../logging/slf4j/LoggerContextRule.java | 72 -------- .../logging/slf4j/LoggerContextSource.java | 53 ++++++ .../apache/logging/slf4j/LoggerResolver.java | 79 +++++++++ .../org/apache/logging/slf4j/LoggerTest.java | 30 ++-- .../logging/slf4j/CallerInformationTest.xml} | 0 .../apache/logging/slf4j/LogBuilderTest.xml} | 0 .../apache/logging/slf4j/LoggerTest.xml} | 0 12 files changed, 333 insertions(+), 107 deletions(-) create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java delete mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java rename log4j-to-slf4j/src/test/resources/{logback-calling-class.xml => org/apache/logging/slf4j/CallerInformationTest.xml} (100%) rename log4j-to-slf4j/src/test/resources/{logback-turbofilter.xml => org/apache/logging/slf4j/LogBuilderTest.xml} (100%) rename log4j-to-slf4j/src/test/resources/{logback-slf4j.xml => org/apache/logging/slf4j/LoggerTest.xml} (100%) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index cf5de79..546beda 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -95,6 +95,11 @@ test-jar test + + org.apache.logging.log4j + log4j-api-test + test + 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 index d8c0f86..513b896 100644 --- 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 @@ -21,18 +21,15 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.testUtil.StringListAppender; import org.apache.logging.log4j.LogManager; -import org.junit.ClassRule; -import org.junit.Test; +import org.apache.logging.log4j.test.junit.UsingStatusListener; +import org.junit.jupiter.api.Test; import static org.junit.Assert.*; +@UsingStatusListener +@LoggerContextSource public class CallerInformationTest { - private static final String CONFIG = "target/test-classes/logback-calling-class.xml"; - - @ClassRule - public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); - @Test public void testClassLogger() throws Exception { final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger"); 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 index dab6983..756eb0e 100644 --- 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 @@ -18,11 +18,12 @@ import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.assertj.core.api.Assertions.assertThat; + /** * Tests LOG4J2-1688 Multiple loggings of arguments are setting these arguments to null. */ @@ -45,14 +46,13 @@ public void testLog4j2() { // 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 - Assert.assertArrayEquals(originalArgs, args); - System.out.println("args are still ok: " + Arrays.toString(args)); + 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)); - Assert.assertArrayEquals(originalArgs, args); + assertThat(args).containsExactly(originalArgs); } /** 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 index 1cd7c35..ea78324 100644 --- 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 @@ -20,7 +20,6 @@ import java.util.stream.Stream; import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.testUtil.StringListAppender; import org.apache.logging.log4j.CloseableThreadContext; @@ -30,33 +29,31 @@ 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; -import org.slf4j.LoggerFactory; import static org.assertj.core.api.Assertions.assertThat; +@UsingStatusListener +@LoggerContextSource public class LogBuilderTest { - private static final String CONFIG = "target/test-classes/logback-turbofilter.xml"; 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"; - private static LoggerContext context; + // Log4j objects private static Logger logger; + // Logback objects + private static LoggerContext context; private static StringListAppender list; @BeforeAll public static void setUp() throws Exception { - context = (LoggerContext) LoggerFactory.getILoggerFactory(); - final JoranConfigurator configurator = new JoranConfigurator(); - configurator.setContext(context); - configurator.doConfigure(CONFIG); - final org.slf4j.Logger slf4jLogger = context.getLogger(LogBuilderTest.class); logger = LogManager.getLogger(LogBuilderTest.class); assertThat(slf4jLogger).isSameAs(((SLF4JLogger) logger).getLogger()); 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 new file mode 100644 index 0000000..473aba8 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java @@ -0,0 +1,165 @@ +/* + * 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.URL; + +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 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 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/LoggerContextRule.java b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.java deleted file mode 100644 index 8697931..0000000 --- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextRule.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.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.GenericConfigurator; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.slf4j.LoggerFactory; - -/** - * JUnit {@link TestRule} similar to the TestRule in {@code log4j-core} of the same name. - * - * @since 2.1 - * @since 2.4.1 Renamed InitialLoggerContext to LoggerContextRule - */ -public class LoggerContextRule implements TestRule { - - private final String configLocation; - - private LoggerContext context; - - private String testClassName; - - public LoggerContextRule(final String configLocation) { - this.configLocation = configLocation; - } - - @Override - public Statement apply(final Statement base, final Description description) { - testClassName = description.getClassName(); - return new Statement() { - @Override - public void evaluate() throws Throwable { - context = (LoggerContext) LoggerFactory.getILoggerFactory(); - final GenericConfigurator configurator = new JoranConfigurator(); - configurator.setContext(context); - configurator.doConfigure(configLocation); - base.evaluate(); - } - }; - } - - public LoggerContext getContext() { - return context; - } - - public Logger getLogger() { - return context.getLogger(testClassName); - } - - public Logger getLogger(final String name) { - return context.getLogger(name); - } -} 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 new file mode 100644 index 0000000..8e3f083 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java @@ -0,0 +1,53 @@ +/* + * 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. + *

+ * 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}. + *

+ */ + 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 new file mode 100644 index 0000000..793143d --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java @@ -0,0 +1,79 @@ +/* + * 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 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 index 1b9e4b8..d513e47 100644 --- 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 @@ -21,6 +21,7 @@ import java.util.Date; import java.util.List; +import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.testUtil.StringListAppender; import org.apache.logging.log4j.LogManager; @@ -31,30 +32,31 @@ import org.apache.logging.log4j.message.StringFormatterMessageFactory; import org.apache.logging.log4j.spi.AbstractLogger; import org.apache.logging.log4j.spi.MessageFactory2Adapter; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; +import org.apache.logging.log4j.test.junit.UsingStatusListener; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.MDC; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +@UsingStatusListener +@LoggerContextSource public class LoggerTest { - private static final String CONFIG = "target/test-classes/logback-slf4j.xml"; - - @ClassRule - public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG); - + private static final Object OBJ = new Object(); + // Log4j objects private Logger logger; + // Logback objects + private LoggerContext context; private StringListAppender list; - @Before + @BeforeEach public void setUp() throws Exception { - final org.slf4j.Logger slf4jLogger = CTX.getLogger(); + 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 = CTX.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + 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())); @@ -78,14 +80,14 @@ public void basicFlowDepreacted() { @Test public void simpleFlowDeprecated() { - logger.entry(CONFIG); + logger.entry(OBJ); logger.exit(0); assertThat(list.strList, hasSize(2)); } @Test public void simpleFlow() { - logger.entry(CONFIG); + logger.entry(OBJ); logger.traceExit(0); assertThat(list.strList, hasSize(2)); } @@ -175,7 +177,7 @@ public void paramIncludesSubstitutionMarker_locationAware() { @Test public void paramIncludesSubstitutionMarker_nonLocationAware() { - final org.slf4j.Logger slf4jLogger = CTX.getLogger(); + final org.slf4j.Logger slf4jLogger = context.getLogger(getClass()); final Logger nonLocationAwareLogger = new SLF4JLogger( slf4jLogger.getName(), (org.slf4j.Logger) Proxy.newProxyInstance( diff --git a/log4j-to-slf4j/src/test/resources/logback-calling-class.xml b/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml similarity index 100% rename from log4j-to-slf4j/src/test/resources/logback-calling-class.xml rename to log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml diff --git a/log4j-to-slf4j/src/test/resources/logback-turbofilter.xml b/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml similarity index 100% rename from log4j-to-slf4j/src/test/resources/logback-turbofilter.xml rename to log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml diff --git a/log4j-to-slf4j/src/test/resources/logback-slf4j.xml b/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml similarity index 100% rename from log4j-to-slf4j/src/test/resources/logback-slf4j.xml rename to log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml From b330206abcea373cb2140c2d4c15a467c91926e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Wed, 1 Nov 2023 14:09:12 +0100 Subject: [PATCH 345/363] Remove unused Maven properties --- log4j-to-slf4j/pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 546beda..9ba0080 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -28,8 +28,6 @@ Apache Log4j to SLF4J Adapter The Apache Log4j binding between Log4j 2 API and SLF4J. - SLF4J Documentation - /log4j-to-slf4j - 3 + [1.7,3) - org.slf4j.*;version="${range;[==,${slf4j.support.bound})}" + org.slf4j.*;version="${slf4j.support.range}" + + + org.slf4j;substitute="slf4j-api" + From 9acc9249c86ab0833e2c73cd028273464fd2dff6 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 20 Dec 2023 12:38:10 +0100 Subject: [PATCH 348/363] Fix NPE caused by MDCContextMap --- log4j-to-slf4j/pom.xml | 5 ++ .../apache/logging/slf4j/MDCContextMap.java | 6 +-- .../logging/slf4j/MDCContextMapTest.java | 50 +++++++++++++++++++ .../test/java/org/slf4j/MDCTestHelper.java | 28 +++++++++++ 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java create mode 100644 log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 24f9d42..bc01ffe 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -103,6 +103,11 @@ log4j-api-test test + + org.mockito + mockito-core + test + 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 index 7f8424c..4f2ef19 100644 --- 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 @@ -16,6 +16,7 @@ */ 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; @@ -75,13 +76,12 @@ public boolean containsKey(final String key) { } @Override - @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API public Map getCopy() { - return MDC.getCopyOfContextMap(); + final Map contextMap = MDC.getCopyOfContextMap(); + return contextMap != null ? contextMap : new HashMap<>(); } @Override - @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API public Map getImmutableMapOrNull() { return MDC.getCopyOfContextMap(); } 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 new file mode 100644 index 0000000..6673de4 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java @@ -0,0 +1,50 @@ +/* + * 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/slf4j/MDCTestHelper.java b/log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java new file mode 100644 index 0000000..0256131 --- /dev/null +++ b/log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java @@ -0,0 +1,28 @@ +/* + * 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; + } +} From be8d47aaaf932021727db7b5f1a2808da4421b54 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Mon, 15 Jan 2024 12:50:19 +0100 Subject: [PATCH 349/363] Expand wildcard imports --- .../logging/slf4j/CallerInformationTest.java | 2 +- .../java/org/apache/logging/slf4j/LoggerTest.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) 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 index 36b788e..b43a4ea 100644 --- 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 @@ -16,7 +16,7 @@ */ package org.apache.logging.slf4j; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.testUtil.StringListAppender; 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 index afb4d62..5f89d5a 100644 --- 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 @@ -16,8 +16,18 @@ */ package org.apache.logging.slf4j; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +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; From 877eaacef40baf32aa65ae4aa587d14f91276dae Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Thu, 21 Dec 2023 13:15:17 +0100 Subject: [PATCH 350/363] Simplify configuration after BND 7.x upgrade BND 7.x supports multi-release JARs, so we can remove many manual overrides of module names. We also **add** an override from `disruptor` to `com.conversantmedia.disruptor`, since new (Java 11 based) versions of `com.conversantmetida:disruptor` have a JPMS descriptor. --- log4j-to-slf4j/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index bc01ffe..d5d1c4e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -37,11 +37,6 @@ org.slf4j.*;version="${slf4j.support.range}" - - - org.slf4j;substitute="slf4j-api" - From b2f528fb1e0159dc9dc6afa9e483e4ea46f8ac82 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Tue, 19 Mar 2024 14:11:41 +0100 Subject: [PATCH 351/363] Remove reflection from `log4j-to-jul` and `log4j-to-slf4j` By removing the reflective instantiation of `LoggerContextFactory` and `ThreadContextMap`, we make `log4j-to-jul` and `log4j-to-slf4j` more GraalVM-friendly. --- .../apache/logging/slf4j/SLF4JProvider.java | 18 +++++++++++++++++- .../org/apache/logging/slf4j/package-info.java | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) 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 index b8514c4..318d793 100644 --- 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 @@ -18,14 +18,30 @@ 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; /** * Bind the Log4j API to SLF4J. */ @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, "2.6.0", SLF4JLoggerContextFactory.class, MDCContextMap.class); + super(15, CURRENT_VERSION); + } + + @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 index e354601..ba4cb13 100644 --- 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 @@ -18,7 +18,7 @@ * SLF4J support. */ @Export -@Version("2.20.1") +@Version("2.24.0") package org.apache.logging.slf4j; import org.osgi.annotation.bundle.Export; From a77faebdc71bd4136814e992b16df0400b63e6fb Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sat, 30 Mar 2024 23:12:09 +0100 Subject: [PATCH 352/363] Move SLF4J dependencies to SLF4J-related modules --- log4j-to-slf4j/pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index d5d1c4e..6b3840e 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -37,7 +37,20 @@ org.slf4j.*;version="${slf4j.support.range}" + + 2.0.9 + + + + + org.slf4j + slf4j-api + ${slf4j2.version} + + + + org.osgi From c103f43b2b8fccaa010951c3d8c6e8be80d272d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Thu, 25 Apr 2024 17:24:53 +0200 Subject: [PATCH 353/363] Improve name/description of SLF4J-related modules (#1462) --- log4j-to-slf4j/pom.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 6b3840e..fdcb488 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -16,17 +16,23 @@ ~ limitations under the License. --> + 4.0.0 + org.apache.logging.log4j log4j ${revision} ../log4j-parent + log4j-to-slf4j - jar - Apache Log4j to SLF4J Adapter - The Apache Log4j binding between Log4j 2 API and SLF4J. + + Log4j API to SLF4J Adapter + + Forwards the Log4j API calls to SLF4J. + (Refer to the `log4j-slf4j[2]-impl` artifacts for forwarding SLF4J to the Log4j API.) + [1.7,3) + + org.jspecify.*;resolution:=optional, org.slf4j.*;version="${slf4j.support.range}" @@ -63,6 +65,11 @@ org.osgi.core provided + + org.jspecify + jspecify + provided + org.apache.logging.log4j log4j-api 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 index 318d793..52a11a5 100644 --- 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 @@ -21,10 +21,12 @@ 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 { @@ -32,7 +34,7 @@ public class SLF4JProvider extends Provider { private static final ThreadContextMap THREAD_CONTEXT_MAP = new MDCContextMap(); public SLF4JProvider() { - super(15, CURRENT_VERSION); + super(15, CURRENT_VERSION, SLF4JLoggerContextFactory.class, MDCContextMap.class); } @Override From a8e8c7614c1fc21f1e1262ec959f72c8f8a98873 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sun, 8 Sep 2024 10:58:36 +0200 Subject: [PATCH 356/363] Fail build for `static transitive` modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a Groovy script that fails the build if any optional JPMS module has the `transitive` qualifier. We remove the `transitive` modifier from all optional dependencies. Closes #2929. Co-authored-by: Volkan Yazıcı --- log4j-to-slf4j/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 4590709..50732f2 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -45,6 +45,10 @@ org.slf4j.*;version="${slf4j.support.range}" + + + org.jspecify;transitive=false + 2.0.16 From c825f4e5ebb05ab6f30998188c4ae7db122e88e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Mon, 16 Sep 2024 13:15:33 +0200 Subject: [PATCH 357/363] Implement `MessageFactory`-namespaced logger registry (#2936) Co-authored-by: Piotr P. Karwasz --- .../logging/slf4j/SLF4JLoggerContext.java | 34 ++++++++++++------- .../apache/logging/slf4j/package-info.java | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) 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 index f0aee0a..4e4567d 100644 --- 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 @@ -17,14 +17,20 @@ package org.apache.logging.slf4j; import org.apache.logging.log4j.message.MessageFactory; +import org.apache.logging.log4j.message.ParameterizedMessageFactory; import org.apache.logging.log4j.spi.ExtendedLogger; import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.LoggerRegistry; +import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SLF4JLoggerContext implements LoggerContext { + private final LoggerRegistry loggerRegistry = new LoggerRegistry<>(); + private static final MessageFactory DEFAULT_MESSAGE_FACTORY = ParameterizedMessageFactory.INSTANCE; + @Override public Object getExternalContext() { return null; @@ -32,29 +38,31 @@ public Object getExternalContext() { @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); + return getLogger(name, null); } @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); + public ExtendedLogger getLogger(final String name, @Nullable final MessageFactory messageFactory) { + final MessageFactory effectiveMessageFactory = + messageFactory != null ? messageFactory : DEFAULT_MESSAGE_FACTORY; + return loggerRegistry.computeIfAbsent(name, effectiveMessageFactory, SLF4JLoggerContext::createLogger); + } + + private static ExtendedLogger createLogger(final String name, @Nullable final MessageFactory messageFactory) { + final Logger logger = LoggerFactory.getLogger(name); + return new SLF4JLogger(name, messageFactory, logger); } @Override public boolean hasLogger(final String name) { - return loggerRegistry.hasLogger(name); + return loggerRegistry.hasLogger(name, DEFAULT_MESSAGE_FACTORY); } @Override - public boolean hasLogger(final String name, final MessageFactory messageFactory) { - return loggerRegistry.hasLogger(name, messageFactory); + public boolean hasLogger(final String name, @Nullable final MessageFactory messageFactory) { + final MessageFactory effectiveMessageFactory = + messageFactory != null ? messageFactory : DEFAULT_MESSAGE_FACTORY; + return loggerRegistry.hasLogger(name, effectiveMessageFactory); } @Override 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 index ba4cb13..8e6a1c3 100644 --- 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 @@ -18,7 +18,7 @@ * SLF4J support. */ @Export -@Version("2.24.0") +@Version("2.25.0") package org.apache.logging.slf4j; import org.osgi.annotation.bundle.Export; From dab4c9c7cb4ccd09820eca3ee40d6478db61e2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Tue, 17 Sep 2024 20:39:29 +0200 Subject: [PATCH 358/363] Improvements on the logger message factory namespacing (#2936) --- .../main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 4e4567d..ba2a1d4 100644 --- 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 @@ -38,7 +38,7 @@ public Object getExternalContext() { @Override public ExtendedLogger getLogger(final String name) { - return getLogger(name, null); + return getLogger(name, DEFAULT_MESSAGE_FACTORY); } @Override From 9b31ee48c503c9a0980e54e2b42025df21061532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Tue, 17 Sep 2024 20:39:29 +0200 Subject: [PATCH 359/363] Implement `MessageFactory`-namespaced logger registry (#2961) --- .../logging/slf4j/SLF4JLoggerContext.java | 17 +++++++++++------ .../org/apache/logging/slf4j/package-info.java | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) 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 index ba2a1d4..e16a9a1 100644 --- 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 @@ -21,7 +21,6 @@ import org.apache.logging.log4j.spi.ExtendedLogger; import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.LoggerRegistry; -import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,17 +37,23 @@ public Object getExternalContext() { @Override public ExtendedLogger getLogger(final String name) { - return getLogger(name, DEFAULT_MESSAGE_FACTORY); + return getLogger(name, null); } @Override - public ExtendedLogger getLogger(final String name, @Nullable final MessageFactory messageFactory) { + public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) { final MessageFactory effectiveMessageFactory = messageFactory != null ? messageFactory : DEFAULT_MESSAGE_FACTORY; - return loggerRegistry.computeIfAbsent(name, effectiveMessageFactory, SLF4JLoggerContext::createLogger); + final ExtendedLogger oldLogger = loggerRegistry.getLogger(name, effectiveMessageFactory); + if (oldLogger != null) { + return oldLogger; + } + final ExtendedLogger newLogger = createLogger(name, effectiveMessageFactory); + loggerRegistry.putIfAbsent(name, effectiveMessageFactory, newLogger); + return loggerRegistry.getLogger(name, effectiveMessageFactory); } - private static ExtendedLogger createLogger(final String name, @Nullable final MessageFactory messageFactory) { + private static ExtendedLogger createLogger(final String name, final MessageFactory messageFactory) { final Logger logger = LoggerFactory.getLogger(name); return new SLF4JLogger(name, messageFactory, logger); } @@ -59,7 +64,7 @@ public boolean hasLogger(final String name) { } @Override - public boolean hasLogger(final String name, @Nullable final MessageFactory messageFactory) { + public boolean hasLogger(final String name, final MessageFactory messageFactory) { final MessageFactory effectiveMessageFactory = messageFactory != null ? messageFactory : DEFAULT_MESSAGE_FACTORY; return loggerRegistry.hasLogger(name, effectiveMessageFactory); 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 index 8e6a1c3..12e4bed 100644 --- 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 @@ -18,7 +18,7 @@ * SLF4J support. */ @Export -@Version("2.25.0") +@Version("2.24.1") package org.apache.logging.slf4j; import org.osgi.annotation.bundle.Export; From 9c8e5f0d69a9fe19f37084b2a5f44027fb55338d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Tue, 17 Sep 2024 21:11:00 +0200 Subject: [PATCH 360/363] Improvements on the logger message factory namespacing (#2961) --- .../main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index e16a9a1..407a963 100644 --- 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 @@ -37,7 +37,7 @@ public Object getExternalContext() { @Override public ExtendedLogger getLogger(final String name) { - return getLogger(name, null); + return getLogger(name, DEFAULT_MESSAGE_FACTORY); } @Override From 635a51a0e793cfba5ff05cf21c16e99ef27b8b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Kr=C3=BCger?= Date: Thu, 3 Oct 2024 09:15:52 +0200 Subject: [PATCH 361/363] Migrate `log4j-to-slf4j` to JUnit5 (#3040) --- log4j-to-slf4j/pom.xml | 5 ---- .../logging/slf4j/CallerInformationTest.java | 10 +++---- .../org/apache/logging/slf4j/LoggerTest.java | 26 +++++++++---------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml index 50732f2..68f3051 100644 --- a/log4j-to-slf4j/pom.xml +++ b/log4j-to-slf4j/pom.xml @@ -102,11 +102,6 @@ junit-jupiter-params test - - org.junit.vintage - junit-vintage-engine - test - ch.qos.logback logback-classic 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 index b43a4ea..ab6c5bc 100644 --- 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 @@ -16,7 +16,7 @@ */ package org.apache.logging.slf4j; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.testUtil.StringListAppender; @@ -37,9 +37,9 @@ public void testClassLogger() throws Exception { logger.warn("Verifying the caller class is still correct."); logger.error("Hopefully nobody breaks me!"); final List messages = app.strList; - assertEquals("Incorrect number of messages.", 3, messages.size()); + assertEquals(3, messages.size(), "Incorrect number of messages."); for (final String message : messages) { - assertEquals("Incorrect caller class name.", this.getClass().getName(), message); + assertEquals(this.getClass().getName(), message, "Incorrect caller class name."); } } @@ -53,9 +53,9 @@ public void testMethodLogger() throws Exception { logger.warn("brains~~~"); logger.info("Itchy. Tasty."); final List messages = app.strList; - assertEquals("Incorrect number of messages.", 5, messages.size()); + assertEquals(5, messages.size(), "Incorrect number of messages."); for (final String message : messages) { - assertEquals("Incorrect caller method name.", "testMethodLogger", message); + assertEquals("testMethodLogger", message, "Incorrect caller method name."); } } } 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 index 5f89d5a..c6a3cec 100644 --- 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 @@ -16,18 +16,18 @@ */ package org.apache.logging.slf4j; +import static org.hamcrest.MatcherAssert.assertThat; 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 static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; @@ -213,7 +213,7 @@ public void testImpliedThrowable() { final List msgs = list.strList; assertThat(msgs, hasSize(1)); final String expected = "java.lang.Throwable: Testing"; - assertTrue("Incorrect message data", msgs.get(0).contains(expected)); + assertTrue(msgs.get(0).contains(expected), "Incorrect message data"); } @SuppressWarnings("unchecked") @@ -224,24 +224,24 @@ public void mdc() { ThreadContext.clearMap(); logger.debug("Debug message"); assertThat(list.strList, hasSize(2)); - assertTrue("Incorrect year", list.strList.get(0).startsWith("2010")); + assertTrue(list.strList.get(0).startsWith("2010"), "Incorrect year"); } @Test public void mdcNullBackedIsEmpty() { - assertNull("Setup wrong", MDC.getCopyOfContextMap()); + assertNull(MDC.getCopyOfContextMap(), "Setup wrong"); assertTrue(ThreadContext.isEmpty()); } @Test public void mdcNullBackedContainsKey() { - assertNull("Setup wrong", MDC.getCopyOfContextMap()); + assertNull(MDC.getCopyOfContextMap(), "Setup wrong"); assertFalse(ThreadContext.containsKey("something")); } @Test public void mdcNullBackedContainsNullKey() { - assertNull("Setup wrong", MDC.getCopyOfContextMap()); + assertNull(MDC.getCopyOfContextMap(), "Setup wrong"); assertFalse(ThreadContext.containsKey(null)); } @@ -249,7 +249,7 @@ public void mdcNullBackedContainsNullKey() { public void mdcContainsNullKey() { try { ThreadContext.put("some", "thing"); - assertNotNull("Setup wrong", MDC.getCopyOfContextMap()); + assertNotNull(MDC.getCopyOfContextMap(), "Setup wrong"); assertFalse(ThreadContext.containsKey(null)); } finally { ThreadContext.clearMap(); From 5bd7ee06f4d5f16210571bf52514c023cf8679d8 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 6 Nov 2024 12:36:55 +0100 Subject: [PATCH 362/363] Rename artifact --- {log4j-to-slf4j => log4j-api-to-slf4j}/pom.xml | 0 .../src/main/java/org/apache/logging/slf4j/Activator.java | 0 .../src/main/java/org/apache/logging/slf4j/MDCContextMap.java | 0 .../src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java | 0 .../src/main/java/org/apache/logging/slf4j/SLF4JLogger.java | 0 .../main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java | 0 .../java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java | 0 .../src/main/java/org/apache/logging/slf4j/SLF4JProvider.java | 0 .../src/main/java/org/apache/logging/slf4j/package-info.java | 0 .../META-INF/services/org.apache.logging.log4j.spi.Provider | 0 .../test/java/org/apache/logging/slf4j/CallerInformationTest.java | 0 .../test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java | 0 .../src/test/java/org/apache/logging/slf4j/LogBuilderTest.java | 0 .../test/java/org/apache/logging/slf4j/LoggerContextResolver.java | 0 .../test/java/org/apache/logging/slf4j/LoggerContextSource.java | 0 .../src/test/java/org/apache/logging/slf4j/LoggerResolver.java | 0 .../src/test/java/org/apache/logging/slf4j/LoggerTest.java | 0 .../src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java | 0 .../src/test/java/org/apache/logging/slf4j/TestUtil.java | 0 .../src/test/java/org/slf4j/MDCTestHelper.java | 0 .../resources/org/apache/logging/slf4j/CallerInformationTest.xml | 0 .../test/resources/org/apache/logging/slf4j/LogBuilderTest.xml | 0 .../src/test/resources/org/apache/logging/slf4j/LoggerTest.xml | 0 23 files changed, 0 insertions(+), 0 deletions(-) rename {log4j-to-slf4j => log4j-api-to-slf4j}/pom.xml (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/Activator.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/MDCContextMap.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/java/org/apache/logging/slf4j/package-info.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/LoggerResolver.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/LoggerTest.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/apache/logging/slf4j/TestUtil.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/java/org/slf4j/MDCTestHelper.java (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml (100%) rename {log4j-to-slf4j => log4j-api-to-slf4j}/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml (100%) diff --git a/log4j-to-slf4j/pom.xml b/log4j-api-to-slf4j/pom.xml similarity index 100% rename from log4j-to-slf4j/pom.xml rename to log4j-api-to-slf4j/pom.xml diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/Activator.java diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/MDCContextMap.java diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogBuilder.java diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JProvider.java diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java b/log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java similarity index 100% rename from log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java rename to log4j-api-to-slf4j/src/main/java/org/apache/logging/slf4j/package-info.java diff --git a/log4j-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider b/log4j-api-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider similarity index 100% rename from log4j-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider rename to log4j-api-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/Log4j2Jira1688Test.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextResolver.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerContextSource.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerResolver.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/LoggerTest.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/MDCContextMapTest.java diff --git a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java b/log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java rename to log4j-api-to-slf4j/src/test/java/org/apache/logging/slf4j/TestUtil.java diff --git a/log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java b/log4j-api-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java similarity index 100% rename from log4j-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java rename to log4j-api-to-slf4j/src/test/java/org/slf4j/MDCTestHelper.java diff --git a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml b/log4j-api-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml similarity index 100% rename from log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml rename to log4j-api-to-slf4j/src/test/resources/org/apache/logging/slf4j/CallerInformationTest.xml diff --git a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml b/log4j-api-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml similarity index 100% rename from log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml rename to log4j-api-to-slf4j/src/test/resources/org/apache/logging/slf4j/LogBuilderTest.xml diff --git a/log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml b/log4j-api-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml similarity index 100% rename from log4j-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml rename to log4j-api-to-slf4j/src/test/resources/org/apache/logging/slf4j/LoggerTest.xml From 3b8acf72f512853c16b2a73ad12835f66b0faf48 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 6 Nov 2024 15:30:18 +0100 Subject: [PATCH 363/363] Fix build --- log4j-api-to-slf4j/pom.xml | 87 +++++++------------ .../org.apache.logging.log4j.spi.Provider | 1 - .../org.apache.logging.log4j.spi.Provider | 17 ++++ parent/pom.xml | 71 ++++++++++++++- pom.xml | 11 ++- spotbugs-exclude.xml | 37 ++++++++ 6 files changed, 166 insertions(+), 58 deletions(-) delete mode 100644 log4j-api-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider create mode 100644 log4j-api-to-slf4j/src/test/resources/META-INF/services/org.apache.logging.log4j.spi.Provider create mode 100644 spotbugs-exclude.xml diff --git a/log4j-api-to-slf4j/pom.xml b/log4j-api-to-slf4j/pom.xml index 68f3051..4ff29b1 100644 --- a/log4j-api-to-slf4j/pom.xml +++ b/log4j-api-to-slf4j/pom.xml @@ -16,143 +16,122 @@ ~ limitations under the License. --> - 4.0.0 - org.apache.logging.log4j - log4j + log4j-slf4j-parent ${revision} - ../log4j-parent + ../parent - log4j-to-slf4j + log4j-api-to-slf4j - Log4j API to SLF4J Adapter + Log4j API to SLF4J logging bridge Forwards the Log4j API calls to SLF4J. (Refer to the `log4j-slf4j[2]-impl` artifacts for forwarding SLF4J to the Log4j API.) + + 1.5.12 + 1.8.0 [1.7,3) - - org.jspecify.*;resolution:=optional, org.slf4j.*;version="${slf4j.support.range}" - - - org.jspecify;transitive=false - - - 2.0.16 - - - - org.slf4j - slf4j-api - ${slf4j2.version} - - - - + org.osgi - org.osgi.core - provided - - - org.jspecify - jspecify + org.osgi.framework + ${osgi.framework.version} provided + org.apache.logging.log4j log4j-api + org.slf4j slf4j-api + org.assertj assertj-core test - - org.hamcrest - hamcrest - test - + org.junit.jupiter - junit-jupiter-engine + junit-jupiter-api test + org.junit.jupiter junit-jupiter-params test + ch.qos.logback logback-classic + ${logback.version} test + ch.qos.logback logback-core + ${logback.version} test + ch.qos.logback logback-core + ${logback.version} test-jar test + + org.apache.logging.log4j log4j-api-test test + org.mockito mockito-core test + - + + org.apache.maven.plugins - maven-enforcer-plugin - - - ban-logging-dependencies - - - - - ch.qos.logback:*:*:*:test - - - - - - + maven-surefire-plugin + + false + + diff --git a/log4j-api-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider b/log4j-api-to-slf4j/src/main/resources/META-INF/services/org.apache.logging.log4j.spi.Provider deleted file mode 100644 index c66b5c9..0000000 --- a/log4j-api-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-api-to-slf4j/src/test/resources/META-INF/services/org.apache.logging.log4j.spi.Provider b/log4j-api-to-slf4j/src/test/resources/META-INF/services/org.apache.logging.log4j.spi.Provider new file mode 100644 index 0000000..d0396bb --- /dev/null +++ b/log4j-api-to-slf4j/src/test/resources/META-INF/services/org.apache.logging.log4j.spi.Provider @@ -0,0 +1,17 @@ +# 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 +# +# https://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. +## +# BND can generate this, but we need it faster +org.apache.logging.slf4j.SLF4JProvider \ No newline at end of file diff --git a/parent/pom.xml b/parent/pom.xml index 5a1db4f..cfb8791 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -31,9 +31,19 @@ https://logging.apache.org/log4j/2.x/manual/installation.html + + false + 3.26.3 + 7.0.0 + 2.2 + 1.0.0 + 5.11.3 2.24.1 + 5.14.2 + 2.0.0 + 1.1.2 2.0.16 @@ -41,19 +51,76 @@ + + org.assertj + assertj-bom + ${assertj.version} + pom + import + + + + org.junit + junit-bom + ${junit.version} + pom + import + + org.apache.logging.log4j - log4j-api + log4j-bom ${log4j.version} + pom + import + + + + org.mockito + mockito-bom + ${mockito.version} + pom + import org.slf4j - slf4j-api + slf4j-bom ${slf4j.version} + pom + import + + + + biz.aQute.bnd + biz.aQute.bnd.annotation + ${bnd.annotation.version} + provided + + + + org.jspecify + jspecify + ${jspecify.version} + + + + org.osgi + org.osgi.annotation.bundle + ${osgi.bundle.version} + provided + + + + org.osgi + org.osgi.annotation.versioning + ${osgi.versioning.version} + + + diff --git a/pom.xml b/pom.xml index 02bc526..36841e0 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,7 @@ parent + log4j-api-to-slf4j @@ -97,7 +98,15 @@ - + + + + org.apache.logging.log4j + log4j-api-to-slf4j + ${project.version} + + + diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml new file mode 100644 index 0000000..b0c83f0 --- /dev/null +++ b/spotbugs-exclude.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + +