Repository: logging-log4j2
Updated Branches:
refs/heads/master 2f7a0c8d4 -> b6ff099cf
Beef up Log4j 1.2 to 2 convertion utility. The new test makes it easy to
see what we cannot convert yet (at least what the converter blows up
on).
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b6ff099c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b6ff099c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b6ff099c
Branch: refs/heads/master
Commit: b6ff099cf45dcf4baba0e77d6c6f5ef2eeb458a2
Parents: 2f7a0c8
Author: Gary Gregory
Authored: Fri Sep 23 17:19:05 2016 -0700
Committer: Gary Gregory
Committed: Fri Sep 23 17:19:05 2016 -0700
--
...bstractLog4j1ConfigurationConverterTest.java | 62
.../Log4j1ConfigurationConverterHadoopTest.java | 31 +-
.../Log4j1ConfigurationConverterSparkTest.java | 39
.../test/resources/config-1.2/hadoop/readme.txt | 1 -
.../config-1.2/spark/R/log4j.properties | 28 +
.../src/test/resources/log4j.properties | 27 +
.../src/test/resources/log4j.properties | 24
.../core/src/test/resources/log4j.properties| 36
.../src/test/resources/log4j.properties | 28 +
.../flume/src/test/resources/log4j.properties | 28 +
.../src/test/resources/log4j.properties | 27 +
.../src/test/resources/log4j.properties | 28 +
.../src/test/resources/log4j.properties | 28 +
.../src/main/resources/log4j.properties | 37
.../src/test/resources/log4j.properties | 27 +
.../graphx/src/test/resources/log4j.properties | 27 +
.../src/test/resources/log4j.properties | 33 +++
.../mllib/src/test/resources/log4j.properties | 28 +
.../repl/src/test/resources/log4j.properties| 27 +
.../src/test/resources/log4j.properties | 27 +
.../core/src/test/resources/log4j.properties| 57 ++
.../hive/src/test/resources/log4j.properties| 61 +++
.../src/test/resources/log4j.properties | 28 +
.../yarn/src/test/resources/log4j.properties| 31 ++
24 files changed, 741 insertions(+), 29 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b6ff099c/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java
--
diff --git
a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java
b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java
new file mode 100644
index 000..4afcf78
--- /dev/null
+++
b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java
@@ -0,0 +1,62 @@
+package org.apache.log4j.config;
+
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/*
+ * 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.
+ */
+
+@RunWith(Parameterized.class)
+public abstract class AbstractLog4j1ConfigurationConverterTest {
+
+protected static List getPaths(final String root) throws IOException
{
+final List paths = new ArrayList<>();
+Files.walkFileTree(Paths.get(root), new SimpleFileVisitor() {
+@Override
+public FileVisitResult visitFile(final Path file, final
BasicFileAttributes attrs) throws IOException {
+paths.add(file);
+return FileVisitResult.CONTINUE;
+}
+
Repository: logging-log4j2
Updated Branches:
refs/heads/master 799ca97db -> 2f7a0c8d4
Beef up Log4j 1.2 to 2 convertion utility. The new test makes it easy to
see what we cannot convert yet (at least what the converter blows up
on).
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2f7a0c8d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2f7a0c8d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2f7a0c8d
Branch: refs/heads/master
Commit: 2f7a0c8d4fceb162bd397ab5be7a6fd3a301cab8
Parents: 799ca97
Author: Gary Gregory
Authored: Fri Sep 23 17:11:21 2016 -0700
Committer: Gary Gregory
Committed: Fri Sep 23 17:11:21 2016 -0700
--
log4j-1.2-api/src/test/resources/config-1.2/hadoop/readme.txt | 1 +
1 file changed, 1 insertion(+)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2f7a0c8d/log4j-1.2-api/src/test/resources/config-1.2/hadoop/readme.txt
--
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/hadoop/readme.txt
b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/readme.txt
new file mode 100644
index 000..f14540c
--- /dev/null
+++ b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/readme.txt
@@ -0,0 +1 @@
+These files were all copied from Hadoop sources in Git.
\ No newline at end of file
Repository: logging-log4j2
Updated Branches:
refs/heads/master e58fab172 -> 799ca97db
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/799ca97d/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/resources/log4j.properties
--
diff --git
a/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/resources/log4j.properties
b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/resources/log4j.properties
new file mode 100644
index 000..c088bb7
--- /dev/null
+++
b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/resources/log4j.properties
@@ -0,0 +1,19 @@
+# Licensed 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.
+
+# log4j configuration used during build and unit tests
+
+log4j.rootLogger=INFO,stdout
+log4j.threshold=ALL
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}
(%F:%M(%L)) - %m%n
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/799ca97d/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/resources/log4j.properties
--
diff --git
a/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/resources/log4j.properties
b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/resources/log4j.properties
new file mode 100644
index 000..81a3f6a
--- /dev/null
+++
b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/resources/log4j.properties
@@ -0,0 +1,19 @@
+# Licensed 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.
+
+# log4j configuration used during build and unit tests
+
+log4j.rootLogger=info,stdout
+log4j.threshold=ALL
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}
(%F:%M(%L)) - %m%n
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/799ca97d/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/resources/log4j.properties
--
diff --git
a/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/resources/log4j.properties
b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/resources/log4j.properties
new file mode 100644
index 000..81a3f6a
--- /dev/null
+++
b/log4j-1.2-api/src/test/resources/config-1.2/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/resources/log4j.properties
@@ -0,0 +1,19 @@
+# Licensed 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,
Repository: logging-log4j2
Updated Branches:
refs/heads/master 7a409d4a6 -> fc2a2edd7
Javadoc: Use the active voice.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fc2a2edd
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fc2a2edd
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fc2a2edd
Branch: refs/heads/master
Commit: fc2a2edd7b8f97c97218e8c8e4eb9e8446aa485e
Parents: 7a409d4
Author: Gary Gregory
Authored: Fri Sep 23 15:51:47 2016 -0700
Committer: Gary Gregory
Committed: Fri Sep 23 15:51:47 2016 -0700
--
.../logging/log4j/core/config/ConfigurationException.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fc2a2edd/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java
--
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java
index 06f777e..830cdcf 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java
@@ -25,7 +25,7 @@ public class ConfigurationException extends RuntimeException {
private static final long serialVersionUID = -2413951820300775294L;
/**
- * Construct an exception with a message.
+ * Constructs an exception with a message.
*
* @param message The reason for the exception
*/
@@ -34,7 +34,7 @@ public class ConfigurationException extends RuntimeException {
}
/**
- * Construct an exception with a message and underlying cause.
+ * Constructs an exception with a message and underlying cause.
*
* @param message The reason for the exception
* @param cause The underlying cause of the exception
@@ -44,7 +44,7 @@ public class ConfigurationException extends RuntimeException {
}
/**
- * Construct an exception with a message and underlying cause.
+ * Constructs an exception with a message and underlying cause.
*
* @param cause The underlying cause of the exception
*/
Repository: logging-log4j2
Updated Branches:
refs/heads/master 96cc528db -> e4665a246
Refactor into a basic command line class to hold common options, right
now only "help" but "version" makes sense too and I'll add that later.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e4665a24
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e4665a24
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e4665a24
Branch: refs/heads/master
Commit: e4665a2467e714ccd117a6877e583cd71d1788d0
Parents: 96cc528
Author: Gary Gregory
Authored: Fri Sep 23 15:49:21 2016 -0700
Committer: Gary Gregory
Committed: Fri Sep 23 15:49:21 2016 -0700
--
.../core/net/server/AbstractSocketServer.java | 14 +-
.../core/util/BasicCommandLineArguments.java| 47
2 files changed, 49 insertions(+), 12 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e4665a24/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
--
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
index 8e24c25..ab0c945 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
@@ -35,6 +35,7 @@ import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
import org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory;
+import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
import org.apache.logging.log4j.core.util.InetAddressConverter;
import org.apache.logging.log4j.core.util.Log4jThread;
import org.apache.logging.log4j.util.Strings;
@@ -53,14 +54,11 @@ import com.beust.jcommander.validators.PositiveInteger;
*/
public abstract class AbstractSocketServer extends
LogEventListener implements Runnable {
-protected static class CommandLineArguments {
+protected static class CommandLineArguments extends
BasicCommandLineArguments {
@Parameter(names = { "--config", "-c" }, description = "Log4j
configuration file location (path or URL).")
private String configLocation;
-@Parameter(names = { "--help", "-?", "-h" }, help = true, description
= "Prints this help.")
-private boolean help;
-
@Parameter(names = { "--interactive",
"-i" }, description = "Accepts commands on standard input
(\"exit\" is the only command).")
private boolean interactive;
@@ -81,10 +79,6 @@ public abstract class AbstractSocketServer extends LogEve
return port;
}
-boolean isHelp() {
-return help;
-}
-
protected boolean isInteractive() {
return interactive;
}
@@ -93,10 +87,6 @@ public abstract class AbstractSocketServer extends LogEve
this.configLocation = configLocation;
}
-void setHelp(final boolean help) {
-this.help = help;
-}
-
void setInteractive(final boolean interactive) {
this.interactive = interactive;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e4665a24/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BasicCommandLineArguments.java
--
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BasicCommandLineArguments.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BasicCommandLineArguments.java
new file mode 100644
index 000..71271d8
--- /dev/null
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BasicCommandLineArguments.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
Repository: logging-log4j2
Updated Branches:
refs/heads/master 2ddd7e155 -> 3c2aef1ce
LOG4J2-1611 LOG4J2-1010 create pre-sized StringMap instances to avoid
unnecessary copying.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3c2aef1c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3c2aef1c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3c2aef1c
Branch: refs/heads/master
Commit: 3c2aef1ce33fbdd4fb37f8e4bbf0583613895a00
Parents: 2ddd7e1
Author: rpopma
Authored: Sat Sep 24 00:44:02 2016 +0900
Committer: rpopma
Committed: Sat Sep 24 00:44:02 2016 +0900
--
.../logging/log4j/core/impl/ThreadContextDataInjector.java | 9 -
1 file changed, 4 insertions(+), 5 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3c2aef1c/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
--
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
index 31d273b..54fc06f 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.ThreadContextAccess;
import org.apache.logging.log4j.core.ContextDataInjector;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.util.ReadOnlyStringMap;
+import org.apache.logging.log4j.util.SortedArrayStringMap;
import org.apache.logging.log4j.util.StringMap;
import org.apache.logging.log4j.spi.ThreadContextMap;
@@ -81,7 +82,7 @@ public class ThreadContextDataInjector {
// data. Note that we cannot reuse the specified StringMap: some
Loggers may have properties defined
// and others not, so the LogEvent's context data may have been
replaced with an immutable copy from
// the ThreadContext - this will throw an
UnsupportedOperationException if we try to modify it.
-final StringMap result = ContextDataFactory.createContextData();
+final StringMap result = new SortedArrayStringMap(props.size() +
copy.size());
copyProperties(props, result);
copyThreadContextMap(copy, result);
return result;
@@ -93,9 +94,7 @@ public class ThreadContextDataInjector {
if (map instanceof ReadOnlyStringMap) {
return (ReadOnlyStringMap) map;
}
-final StringMap result = ContextDataFactory.createContextData();
-copyThreadContextMap(ThreadContext.getImmutableContext(), result);
-return result;
+return map.isEmpty() ? EMPTY_STRING_MAP : new
JdkMapAdapterStringMap(map.getImmutableMapOrNull());
}
/**
@@ -176,7 +175,7 @@ public class ThreadContextDataInjector {
// data. Note that we cannot reuse the specified StringMap: some
Loggers may have properties defined
// and others not, so the LogEvent's context data may have been
replaced with an immutable copy from
// the ThreadContext - this will throw an
UnsupportedOperationException if we try to modify it.
-final StringMap result = ContextDataFactory.createContextData();
+final StringMap result = new SortedArrayStringMap(props.size() +
immutableCopy.size());
copyProperties(props, result);
result.putAll(immutableCopy);
return result;
Repository: logging-log4j2
Updated Branches:
refs/heads/master 713f1a9ba -> 006706615
LOG4J2-1010 bugfix in ThreadContextDataInjector.ForCopyOnWriteThreadContext:
prevent potential UnsupportedOperationException when using async loggers and
some loggers have properties configured and some don't
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/281ad99a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/281ad99a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/281ad99a
Branch: refs/heads/master
Commit: 281ad99a011b1952c721e5f3063fc1dc639f1716
Parents: 713f1a9
Author: rpopma
Authored: Fri Sep 23 17:48:46 2016 +0900
Committer: rpopma
Committed: Fri Sep 23 17:48:46 2016 +0900
--
.../log4j/core/impl/ThreadContextDataInjector.java | 17 ++---
1 file changed, 10 insertions(+), 7 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/281ad99a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
--
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
index d26324c..92144c4 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
@@ -144,22 +144,25 @@ public class ThreadContextDataInjector {
* specified reusable StringMap.
*
* @param props list of configuration properties, may be {@code null}
- * @param reusable a {@code StringMap} instance that may be reused to
avoid creating temporary objects
+ * @param ignore a {@code StringMap} instance from the log event
* @return a {@code StringMap} combining configuration properties with
thread context data
*/
@Override
-public StringMap injectContextData(final List props, final
StringMap reusable) {
+public StringMap injectContextData(final List props, final
StringMap ignore) {
// If there are no configuration properties we want to just return
the ThreadContext's StringMap:
// it is a copy-on-write data structure so we are sure
ThreadContext changes will not affect our copy.
final StringMap immutableCopy =
ThreadContextAccess.getThreadContextMap2().getReadOnlyContextData();
if (props == null || props.isEmpty()) {
-return immutableCopy;
+return immutableCopy; // this will replace the LogEvent's
context data with the returned instance
}
// However, if the list of Properties is non-empty we need to
combine the properties and the ThreadContext
-// data. In that case we will copy the key-value pairs into the
specified reusable StringMap.
-copyProperties(props, reusable);
-reusable.putAll(immutableCopy);
-return reusable;
+// data. Note that we cannot reuse the specified StringMap: some
Loggers may have properties defined
+// and others not, so the LogEvent's context data may have been
replaced with an immutable copy from
+// the ThreadContext - this will throw an
UnsupportedOperationException if we try to modify it.
+final StringMap result = ContextDataFactory.createContextData();
+copyProperties(props, result);
+result.putAll(immutableCopy);
+return result;
}
@Override
Repository: logging-log4j2
Updated Branches:
refs/heads/master bb220a0cb -> 42da9595b
LOG4J2-1010 even better javadoc for LogEvent::getContextData
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/42da9595
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/42da9595
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/42da9595
Branch: refs/heads/master
Commit: 42da9595b9cafbba3c7e033d66ab49cc6f1c5aa5
Parents: bb220a0
Author: rpopma
Authored: Fri Sep 23 17:18:39 2016 +0900
Committer: rpopma
Committed: Fri Sep 23 17:18:39 2016 +0900
--
.../src/main/java/org/apache/logging/log4j/core/LogEvent.java | 7 ---
1 file changed, 4 insertions(+), 3 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/42da9595/log4j-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
--
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
index 677e9e7..1b608b9 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
@@ -61,9 +61,10 @@ public interface LogEvent extends Serializable {
* Returns the {@code ReadOnlyStringMap} object holding context data
key-value pairs.
*
* Context data (also known as Mapped Diagnostic Context or MDC) is data
that is set by the application to be
- * included in all subsequent log events. The default source for context
data is the {@link ThreadContext},
- * but users can configure a custom {@link ContextDataInjector} to obtain
key-value pairs from any arbitrary
- * source.
+ * included in all subsequent log events. The default source for context
data is the {@link ThreadContext} (and
+ * https://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution;>properties
+ * configured on the Logger that logged the event), but users can
configure a custom {@link ContextDataInjector}
+ * to inject key-value pairs from any arbitrary source.
*
* @return the {@code ReadOnlyStringMap} object holding context data
key-value pairs
* @see ContextDataInjector
Repository: logging-log4j2
Updated Branches:
refs/heads/master 679c4aba6 -> 383135357
Clarify Javadocs.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/38313535
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/38313535
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/38313535
Branch: refs/heads/master
Commit: 3831353570467885f1bddf10d286e6b2b609423c
Parents: 679c4ab
Author: Gary Gregory
Authored: Thu Sep 22 23:35:19 2016 -0700
Committer: Gary Gregory
Committed: Thu Sep 22 23:35:19 2016 -0700
--
.../log4j/config/Log4j1ConfigurationParser.java | 23 ++--
1 file changed, 11 insertions(+), 12 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/38313535/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
--
diff --git
a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
index 16c9b7c..d71349e 100644
---
a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
+++
b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
@@ -73,18 +73,17 @@ public class Log4j1ConfigurationParser {
private final ConfigurationBuilder builder =
ConfigurationBuilderFactory
.newConfigurationBuilder();
- /**
-* Parse a Log4j 1.2 properties configuration file into a
-* ConfigurationBuilder.
-*
-* @param input
-*InputStream to read from, will not be closed.
-* @return the populated ConfigurationBuilder, never {@literal null}
-* @throws IOException
-* if unable to read the input
-* @throws ConfigurationException
-* if the input does not contain a valid configuration
-*/
+/**
+ * Parses a Log4j 1.2 properties configuration file in ISO 8859-1 encoding
into a ConfigurationBuilder.
+ *
+ * @param input
+ *InputStream to read from is assumed to be ISO 8859-1, and
will not be closed.
+ * @return the populated ConfigurationBuilder, never {@literal null}
+ * @throws IOException
+ * if unable to read the input
+ * @throws ConfigurationException
+ * if the input does not contain a valid configuration
+ */
public ConfigurationBuilder
buildConfigurationBuilder(final InputStream input)
throws IOException {
properties.load(input);