You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ck...@apache.org on 2018/04/07 21:38:45 UTC
[1/2] logging-log4j2 git commit: LOG4J2-2032 Curly braces in
parameters should not be treated as placeholders
Repository: logging-log4j2
Updated Branches:
refs/heads/master 324d354a3 -> 078808c65
LOG4J2-2032 Curly braces in parameters should not be treated as placeholders
When logging event parameter contains two consecutive opening and
closing curly braces - for example {} in the middle of parameter,
they should not be treated as a placeholder.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/078808c6
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/078808c6
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/078808c6
Branch: refs/heads/master
Commit: 078808c65dd0d53e3e17d925ce3d613aea23a606
Parents: 3063677
Author: Kostiantyn Shchepanovskyi <ko...@playtech.com>
Authored: Tue Feb 6 13:26:00 2018 +0200
Committer: Carter Kozak <ck...@apache.org>
Committed: Sat Apr 7 17:38:31 2018 -0400
----------------------------------------------------------------------
.../AsyncAppenderConfigTest_LOG4J2_2032.java | 64 ++++++++++++++++++++
.../AsyncAppenderConfigTest-LOG4J2-2032.xml | 23 +++++++
src/changes/changes.xml | 3 +
3 files changed, 90 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/078808c6/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java
new file mode 100644
index 0000000..fa5ddf4
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.async;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.CoreLoggerContexts;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+@Category(AsyncLoggers.class)
+public class AsyncAppenderConfigTest_LOG4J2_2032 {
+
+ @BeforeClass
+ public static void beforeClass() {
+ System.setProperty("Log4jLogEventFactory", "org.apache.logging.log4j.core.impl.ReusableLogEventFactory");
+ System.setProperty("log4j2.messageFactory", "org.apache.logging.log4j.message.ReusableMessageFactory");
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncAppenderConfigTest-LOG4J2-2032.xml");
+ }
+
+ @Test
+ public void doNotProcessPlaceholdersTwice() throws Exception {
+ final File file = new File("target", "AsyncAppenderConfigTest-LOG4J2-2032.log");
+ assertTrue("Deleted old file before test", !file.exists() || file.delete());
+
+ final Logger log = LogManager.getLogger("com.foo.Bar");
+ log.info("Text containing curly braces: {}", "Curly{}");
+ CoreLoggerContexts.stopLoggerContext(file); // stop async thread
+
+ final BufferedReader reader = new BufferedReader(new FileReader(file));
+ try {
+ final String line1 = reader.readLine();
+ System.out.println(line1);
+ assertTrue("line1 correct", line1.contains(" Text containing curly braces: Curly{} "));
+ } finally {
+ reader.close();
+ file.delete();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/078808c6/log4j-core/src/test/resources/AsyncAppenderConfigTest-LOG4J2-2032.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/AsyncAppenderConfigTest-LOG4J2-2032.xml b/log4j-core/src/test/resources/AsyncAppenderConfigTest-LOG4J2-2032.xml
new file mode 100644
index 0000000..32bb8e9
--- /dev/null
+++ b/log4j-core/src/test/resources/AsyncAppenderConfigTest-LOG4J2-2032.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="ERROR">
+ <Appenders>
+ <File name="File"
+ fileName="target/AsyncAppenderConfigTest-LOG4J2-2032.log"
+ bufferedIO="false"
+ immediateFlush="true"
+ append="false">
+ <PatternLayout>
+ <Pattern>%level{length=1} %date{MMdd-HHmm:ss,SSS} %logger{1.} %message %X [%thread]%n</Pattern>
+ </PatternLayout>
+ </File>
+ <Async name="Async">
+ <AppenderRef ref="File"/>
+ </Async>
+ </Appenders>
+
+ <Loggers>
+ <Root level="info">
+ <AppenderRef ref="Async"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/078808c6/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 50d8a38..50cc46f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -121,6 +121,9 @@
<action issue="LOG4J2-2307" dev="ckozak" type="fix">
MutableLogEvent and RingBufferLogEvent message mementos retain the original format string.
</action>
+ <action issue="LOG4J2-2032" dev="ckozak" type="fix" due-to="Kostiantyn Shchepanovskyi">
+ Curly braces in parameters are not treated as placeholders.
+ </action>
</release>
<release version="2.11.1" date="2018-MM-DD" description="GA Release 2.11.1">
<action issue="LOG4J2-2268" dev="rgoers" type="fix" due-to="Tilman Hausherr">
[2/2] logging-log4j2 git commit: Fix SslConfigurationTest running on
Windows behind proxy
Posted by ck...@apache.org.
Fix SslConfigurationTest running on Windows behind proxy
Corporate proxies might not allow connection to external resources.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3063677a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3063677a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3063677a
Branch: refs/heads/master
Commit: 3063677a89ad8b6a6113c8ab878477e1dd6e34b0
Parents: 324d354
Author: Kostiantyn Shchepanovskyi <ko...@playtech.com>
Authored: Tue Feb 6 12:20:35 2018 +0200
Committer: Carter Kozak <ck...@apache.org>
Committed: Sat Apr 7 17:38:31 2018 -0400
----------------------------------------------------------------------
.../apache/logging/log4j/core/net/ssl/SslConfigurationTest.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3063677a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
index 41349a0..8ddb3e8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.net.ssl;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.ConnectException;
import java.net.UnknownHostException;
import javax.net.ssl.SSLSocket;
@@ -104,6 +105,8 @@ public class SslConfigurationTest {
}
} catch (final UnknownHostException offline) {
// this exception is thrown on Windows when offline
+ } catch (final ConnectException connectionTimeout) {
+ // this exception is thrown on Windows when host is behind a proxy that does not allow connection to external network
}
}
@@ -124,6 +127,8 @@ public class SslConfigurationTest {
}
} catch (final UnknownHostException offline) {
// this exception is thrown on Windows when offline
+ } catch (final ConnectException connectionTimeout) {
+ // this exception is thrown on Windows when host is behind a proxy that does not allow connection to external network
}
}