You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/08/21 22:32:55 UTC

[01/23] logging-log4j2 git commit: Document empty block.

Repository: logging-log4j2
Updated Branches:
  refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure a994f15fb -> 138cb1cec


Document empty block.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/932824ad
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/932824ad
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/932824ad

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 932824ad608ebdfd4dcd2725c80fb5c82f3d8120
Parents: dbe8c3a
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 10:09:27 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 10:09:27 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/logging/log4j/spi/ThreadContextStack.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/932824ad/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
index 8ebf5d9..04d2ece 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
@@ -22,4 +22,5 @@ import org.apache.logging.log4j.ThreadContext;
  * Service provider interface to implement custom NDC behavior for {@link ThreadContext}.
  */
 public interface ThreadContextStack extends ThreadContext.ContextStack {
+    // empty
 }


[06/23] logging-log4j2 git commit: Use Log4jThread to name the thread.

Posted by rp...@apache.org.
Use Log4jThread to name the thread.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f1b61bdd
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f1b61bdd
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f1b61bdd

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: f1b61bddf640ecc5d2c80ea190ff7332577cb787
Parents: 1aa3c3e
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 17:30:16 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 17:30:16 2016 -0700

----------------------------------------------------------------------
 .../core/appender/mom/kafka/KafkaManager.java   | 185 +++++++++----------
 1 file changed, 92 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f1b61bdd/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManager.java
index 4e4a09c..d535e02 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManager.java
@@ -1,93 +1,92 @@
-/*
- * 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.appender.mom.kafka;
-
-import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.kafka.clients.producer.Producer;
-import org.apache.kafka.clients.producer.ProducerRecord;
-import org.apache.logging.log4j.core.appender.AbstractManager;
-import org.apache.logging.log4j.core.config.Property;
-import org.apache.logging.log4j.core.util.Log4jThread;
-
-public class KafkaManager extends AbstractManager {
-
-    public static final String DEFAULT_TIMEOUT_MILLIS = "30000";
-
-    /**
-     * package-private access for testing.
-     */
-    static KafkaProducerFactory producerFactory = new DefaultKafkaProducerFactory();
-
-    private final Properties config = new Properties();
-    private Producer<byte[], byte[]> producer = null;
-    private final int timeoutMillis;
-
-    private final String topic;
-
-    public KafkaManager(final String name, final String topic, final Property[] properties) {
-        super(name);
-        this.topic = topic;
-        config.setProperty("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
-        config.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
-        config.setProperty("batch.size", "0");
-        for (final Property property : properties) {
-            config.setProperty(property.getName(), property.getValue());
-        }
-        this.timeoutMillis = Integer.parseInt(config.getProperty("timeout.ms", DEFAULT_TIMEOUT_MILLIS));
-    }
-
-    @Override
-    public void releaseSub() {
-        if (producer != null) {
-            // This thread is a workaround for this Kafka issue: https://issues.apache.org/jira/browse/KAFKA-1660
-            final Thread closeThread = new Log4jThread(new Runnable() {
-                @Override
-                public void run() {
-                    producer.close();
-                }
-            });
-            closeThread.setName("KafkaManager-CloseThread");
-            closeThread.setDaemon(true); // avoid blocking JVM shutdown
-            closeThread.start();
-            try {
-                closeThread.join(timeoutMillis);
-            } catch (final InterruptedException ignore) {
-                // ignore
-            }
-        }
-    }
-
-    public void send(final byte[] msg) throws ExecutionException, InterruptedException, TimeoutException {
-        if (producer != null) {
-            producer.send(new ProducerRecord<byte[], byte[]>(topic, msg)).get(timeoutMillis, TimeUnit.MILLISECONDS);
-        }
-    }
-
-    public void startup() {
-        producer = producerFactory.newKafkaProducer(config);
-    }
-
-    public String getTopic() {
-        return topic;
-    }
-
-}
+/*
+ * 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.appender.mom.kafka;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.util.Log4jThread;
+
+public class KafkaManager extends AbstractManager {
+
+    public static final String DEFAULT_TIMEOUT_MILLIS = "30000";
+
+    /**
+     * package-private access for testing.
+     */
+    static KafkaProducerFactory producerFactory = new DefaultKafkaProducerFactory();
+
+    private final Properties config = new Properties();
+    private Producer<byte[], byte[]> producer = null;
+    private final int timeoutMillis;
+
+    private final String topic;
+
+    public KafkaManager(final String name, final String topic, final Property[] properties) {
+        super(name);
+        this.topic = topic;
+        config.setProperty("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
+        config.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
+        config.setProperty("batch.size", "0");
+        for (final Property property : properties) {
+            config.setProperty(property.getName(), property.getValue());
+        }
+        this.timeoutMillis = Integer.parseInt(config.getProperty("timeout.ms", DEFAULT_TIMEOUT_MILLIS));
+    }
+
+    @Override
+    public void releaseSub() {
+        if (producer != null) {
+            // This thread is a workaround for this Kafka issue: https://issues.apache.org/jira/browse/KAFKA-1660
+            final Thread closeThread = new Log4jThread(new Runnable() {
+                @Override
+                public void run() {
+                    producer.close();
+                }
+            }, "KafkaManager-CloseThread");
+            closeThread.setDaemon(true); // avoid blocking JVM shutdown
+            closeThread.start();
+            try {
+                closeThread.join(timeoutMillis);
+            } catch (final InterruptedException ignore) {
+                // ignore
+            }
+        }
+    }
+
+    public void send(final byte[] msg) throws ExecutionException, InterruptedException, TimeoutException {
+        if (producer != null) {
+            producer.send(new ProducerRecord<byte[], byte[]>(topic, msg)).get(timeoutMillis, TimeUnit.MILLISECONDS);
+        }
+    }
+
+    public void startup() {
+        producer = producerFactory.newKafkaProducer(config);
+    }
+
+    public String getTopic() {
+        return topic;
+    }
+
+}


[05/23] logging-log4j2 git commit: Remove unused import.

Posted by rp...@apache.org.
Remove unused import.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1aa3c3e2
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1aa3c3e2
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1aa3c3e2

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 1aa3c3e249c5d9727fc784aff094a3da222df809
Parents: 4f793c0
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 17:18:01 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 17:18:01 2016 -0700

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/util/Log4jThreadFactory.java     | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1aa3c3e2/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
index ed07056..333ca0a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
@@ -20,8 +20,6 @@ package org.apache.logging.log4j.core.util;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.logging.log4j.util.Strings;
-
 /**
  * Creates {@link Log4jThreads}.
  * 


[20/23] logging-log4j2 git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/logging-log4j2.git

Posted by rp...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/logging-log4j2.git

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4e820ca5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4e820ca5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4e820ca5

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 4e820ca56d35423e993433c55c0d0eaa2c0cbff8
Parents: 615c0f8 e73d9d4
Author: Gary Gregory <gg...@apache.org>
Authored: Sun Aug 21 11:39:08 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Aug 21 11:39:08 2016 -0700

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      | 312 +------------------
 .../log4j/config/Log4j1ConfigurationParser.java | 301 ++++++++++++++++++
 ...g4j-console-EnhancedPatternLayout.properties |   2 +-
 .../impl/DefaultConfigurationBuilder.java       |  16 +-
 .../DefaultCustomLevelComponentBuilder.java     |   2 +-
 .../PropertiesConfigurationFactory.java         |   3 +-
 .../builder/ConfigurationAssemblerTest.java     |  35 ++-
 .../builder/CustomConfigurationFactory.java     |   7 +-
 8 files changed, 360 insertions(+), 318 deletions(-)
----------------------------------------------------------------------



[21/23] logging-log4j2 git commit: Use status logger to note exception while closing. Revert part of the previous commit.

Posted by rp...@apache.org.
Use status logger to note exception while closing. Revert part of the
previous commit.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ee6d45f6
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ee6d45f6
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ee6d45f6

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: ee6d45f6027e56d685fb55bb49493aad2e605f5f
Parents: 4e820ca
Author: Gary Gregory <gg...@apache.org>
Authored: Sun Aug 21 11:39:58 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Aug 21 11:39:58 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/core/net/server/JmsServer.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ee6d45f6/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
index 047511e..752fc13 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
@@ -21,6 +21,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.Charset;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -106,7 +107,6 @@ public class JmsServer extends LogEventListener implements MessageListener, Life
         jmsManager.release();
     }
 
-    @Override
     public boolean isStarted() {
         return state.get() == State.STARTED;
     }


[23/23] logging-log4j2 git commit: Merge remote-tracking branch 'remotes/origin/master' into LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure

Posted by rp...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/138cb1ce
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/138cb1ce
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/138cb1ce

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 138cb1cecf44e1e812631643457e7e9c934aadf9
Parents: a994f15 e706a22
Author: rpopma <rp...@apache.org>
Authored: Mon Aug 22 07:32:21 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Mon Aug 22 07:32:21 2016 +0900

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      | 312 +------------------
 .../log4j/config/Log4j1ConfigurationParser.java | 301 ++++++++++++++++++
 ...g4j-console-EnhancedPatternLayout.properties |   2 +-
 .../java/org/apache/logging/log4j/Logger.java   |  20 ++
 .../logging/log4j/spi/ThreadContextStack.java   |   1 +
 .../logging/log4j/core/LoggerContext.java       |   1 +
 .../log4j/core/appender/AbstractManager.java    |   2 +
 .../core/appender/mom/kafka/KafkaManager.java   | 185 ++++++-----
 .../core/async/AsyncLoggerConfigDisruptor.java  |   3 +-
 .../log4j/core/async/AsyncLoggerDisruptor.java  |   3 +-
 .../log4j/core/async/DaemonThreadFactory.java   |  51 ---
 .../core/config/ConfigurationScheduler.java     |  15 +-
 .../impl/DefaultConfigurationBuilder.java       |  16 +-
 .../DefaultCustomLevelComponentBuilder.java     |   2 +-
 .../PropertiesConfigurationFactory.java         |   3 +-
 .../apache/logging/log4j/core/jmx/Server.java   |   7 +-
 .../log4j/core/layout/PatternLayout.java        |   4 +-
 .../log4j/core/net/server/JmsServer.java        |   5 +-
 .../logging/log4j/core/util/Log4jThread.java    | 138 ++++----
 .../log4j/core/util/Log4jThreadFactory.java     |  88 ++++++
 .../builder/ConfigurationAssemblerTest.java     |  35 ++-
 .../builder/CustomConfigurationFactory.java     |   7 +-
 .../logging/log4j/junit/LoggerContextRule.java  |   2 -
 .../flume/appender/FlumePersistentManager.java  |  30 +-
 src/site/xdoc/manual/appenders.xml              |  18 +-
 25 files changed, 668 insertions(+), 583 deletions(-)
----------------------------------------------------------------------



[16/23] logging-log4j2 git commit: Close configuration source input stream

Posted by rp...@apache.org.
Close configuration source input stream


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/520170c8
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/520170c8
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/520170c8

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 520170c80442d51bb347171800576770d5b2b5ce
Parents: a85fe0c
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Sun Aug 21 17:08:43 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Sun Aug 21 17:08:43 2016 +0200

----------------------------------------------------------------------
 .../core/config/properties/PropertiesConfigurationFactory.java    | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/520170c8/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
index 8eda63a..1098e8f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
@@ -42,9 +42,8 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
 
     @Override
     public PropertiesConfiguration getConfiguration(final ConfigurationSource source) {
-        final InputStream configStream = source.getInputStream();
         final Properties properties = new Properties();
-        try {
+        try (final InputStream configStream = source.getInputStream()) {
             properties.load(configStream);
         } catch (final IOException ioe) {
             throw new ConfigurationException("Unable to load " + source.toString(), ioe);


[04/23] logging-log4j2 git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/logging-log4j2.git

Posted by rp...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/logging-log4j2.git

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4f793c00
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4f793c00
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4f793c00

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 4f793c00fbc90390b5fe075d5e8840574b0fd03c
Parents: 9afe7ea 5aac1af
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 11:47:21 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 11:47:21 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/core/layout/PatternLayout.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[03/23] logging-log4j2 git commit: Refactor thread factories.

Posted by rp...@apache.org.
Refactor thread factories.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9afe7ea8
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9afe7ea8
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9afe7ea8

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 9afe7ea8544942a6ddea68fbdce4428473d07a06
Parents: 932824a
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 11:47:08 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 11:47:08 2016 -0700

----------------------------------------------------------------------
 .../core/async/AsyncLoggerConfigDisruptor.java  |   3 +-
 .../log4j/core/async/AsyncLoggerDisruptor.java  |   3 +-
 .../log4j/core/async/DaemonThreadFactory.java   |  51 -------
 .../core/config/ConfigurationScheduler.java     |  15 +-
 .../apache/logging/log4j/core/jmx/Server.java   |   7 +-
 .../logging/log4j/core/util/Log4jThread.java    | 138 +++++++++----------
 .../log4j/core/util/Log4jThreadFactory.java     |  90 ++++++++++++
 .../flume/appender/FlumePersistentManager.java  |  30 +---
 8 files changed, 177 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
index d0c9eea..f3565a1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
@@ -28,6 +28,7 @@ import org.apache.logging.log4j.core.impl.LogEventFactory;
 import org.apache.logging.log4j.core.impl.MutableLogEvent;
 import org.apache.logging.log4j.core.impl.ReusableLogEventFactory;
 import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
+import org.apache.logging.log4j.core.util.Log4jThreadFactory;
 import org.apache.logging.log4j.message.ReusableMessage;
 import org.apache.logging.log4j.status.StatusLogger;
 
@@ -176,7 +177,7 @@ public class AsyncLoggerConfigDisruptor implements AsyncLoggerConfigDelegate {
         }
     };
 
-    private static final ThreadFactory THREAD_FACTORY = new DaemonThreadFactory("AsyncLoggerConfig-");
+    private static final ThreadFactory THREAD_FACTORY = Log4jThreadFactory.createDaemonThreadFactory("AsyncLoggerConfig");
 
     private int ringBufferSize;
     private AsyncQueueFullPolicy asyncQueueFullPolicy;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
index 1875ad2..259e22d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Executors;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
+import org.apache.logging.log4j.core.util.Log4jThreadFactory;
 import org.apache.logging.log4j.status.StatusLogger;
 
 import com.lmax.disruptor.ExceptionHandler;
@@ -81,7 +82,7 @@ class AsyncLoggerDisruptor {
         LOGGER.trace("[{}] AsyncLoggerDisruptor creating new disruptor for this context.", contextName);
         ringBufferSize = DisruptorUtil.calculateRingBufferSize("AsyncLogger.RingBufferSize");
         final WaitStrategy waitStrategy = DisruptorUtil.createWaitStrategy("AsyncLogger.WaitStrategy");
-        executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory("AsyncLogger[" + contextName + "]-"));
+        executor = Executors.newSingleThreadExecutor(Log4jThreadFactory.createDaemonThreadFactory("AsyncLogger[" + contextName + "]"));
         backgroundThreadId = DisruptorUtil.getExecutorThreadId(executor);
         asyncQueueFullPolicy = AsyncQueueFullPolicyFactory.create();
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DaemonThreadFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DaemonThreadFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DaemonThreadFactory.java
deleted file mode 100644
index 3267c61..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DaemonThreadFactory.java
+++ /dev/null
@@ -1,51 +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.log4j.core.async;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.logging.log4j.core.util.Log4jThread;
-
-/**
- * ThreadFactory that creates daemon threads for the async loggers.
- */
-public class DaemonThreadFactory implements ThreadFactory {
-
-    private static final AtomicInteger THREAD_NUMBER = new AtomicInteger(1);
-    private final ThreadGroup group;
-    private final String threadNamePrefix;
-
-    public DaemonThreadFactory(final String threadNamePrefix) {
-        this.threadNamePrefix = threadNamePrefix;
-        final SecurityManager securityManager = System.getSecurityManager();
-        group = securityManager != null ? securityManager.getThreadGroup() : Thread.currentThread().getThreadGroup();
-    }
-
-    @Override
-    public Thread newThread(final Runnable runnable) {
-        final Thread thread = new Log4jThread(group, runnable, threadNamePrefix + THREAD_NUMBER.getAndIncrement(), 0);
-        if (!thread.isDaemon()) {
-            thread.setDaemon(true);
-        }
-        if (thread.getPriority() != Thread.NORM_PRIORITY) {
-            thread.setPriority(Thread.NORM_PRIORITY);
-        }
-        return thread;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
index 6a3c1ec..744ed24 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
@@ -16,12 +16,6 @@
  */
 package org.apache.logging.log4j.core.config;
 
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.AbstractLifeCycle;
-import org.apache.logging.log4j.core.async.DaemonThreadFactory;
-import org.apache.logging.log4j.core.util.CronExpression;
-import org.apache.logging.log4j.status.StatusLogger;
-
 import java.util.Date;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ScheduledExecutorService;
@@ -29,6 +23,12 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.AbstractLifeCycle;
+import org.apache.logging.log4j.core.util.CronExpression;
+import org.apache.logging.log4j.core.util.Log4jThreadFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+
 /**
  *
  */
@@ -48,7 +48,8 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
             if (scheduledItems > 5) {
                 scheduledItems = 5;
             }
-            executorService = new ScheduledThreadPoolExecutor(scheduledItems, new DaemonThreadFactory("Log4j2Scheduled-"));
+            executorService = new ScheduledThreadPoolExecutor(scheduledItems,
+                    Log4jThreadFactory.createDaemonThreadFactory("Log4j2Scheduled"));
         } else {
             LOGGER.debug("No scheduled items");
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
index fd14e11..10f343a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
@@ -36,11 +36,11 @@ import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.AsyncAppender;
 import org.apache.logging.log4j.core.async.AsyncLoggerConfig;
 import org.apache.logging.log4j.core.async.AsyncLoggerContext;
-import org.apache.logging.log4j.core.async.DaemonThreadFactory;
 import org.apache.logging.log4j.core.config.LoggerConfig;
 import org.apache.logging.log4j.core.impl.Log4jContextFactory;
 import org.apache.logging.log4j.core.selector.ContextSelector;
 import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.core.util.Log4jThreadFactory;
 import org.apache.logging.log4j.spi.LoggerContextFactory;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.apache.logging.log4j.util.PropertiesUtil;
@@ -59,7 +59,7 @@ public final class Server {
     public static final String DOMAIN = "org.apache.logging.log4j2";
     private static final String PROPERTY_DISABLE_JMX = "log4j2.disable.jmx";
     private static final String PROPERTY_ASYNC_NOTIF = "log4j2.jmx.notify.async";
-    private static final String THREAD_NAME_PREFIX = "log4j2.jmx.notif-";
+    private static final String THREAD_NAME_PREFIX = "log4j2.jmx.notif";
     private static final StatusLogger LOGGER = StatusLogger.getLogger();
     static final Executor executor = isJmxDisabled() ? null : createExecutor();
 
@@ -76,7 +76,8 @@ public final class Server {
     private static ExecutorService createExecutor() {
         final boolean defaultAsync = !Constants.IS_WEB_APP;
         final boolean async = PropertiesUtil.getProperties().getBooleanProperty(PROPERTY_ASYNC_NOTIF, defaultAsync);
-        return async ? Executors.newFixedThreadPool(1, new DaemonThreadFactory(THREAD_NAME_PREFIX)) : null;
+        return async ? Executors.newFixedThreadPool(1, Log4jThreadFactory.createDaemonThreadFactory(THREAD_NAME_PREFIX))
+                : null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThread.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThread.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThread.java
index 1467a54..b92f181 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThread.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThread.java
@@ -1,69 +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.log4j.core.util;
-
-/**
- * Prefixes thread names with {@code "Log4j2-"}.
- */
-public class Log4jThread extends Thread {
-
-    private static final String PREFIX = "Log4j2-";
-
-    private static int threadInitNumber;
-
-    private static synchronized int nextThreadNum() {
-        return threadInitNumber++;
-    }
-
-    private static String toThreadName(final Object name) {
-        return PREFIX + name;
-    }
-
-    public Log4jThread() {
-        super(toThreadName(nextThreadNum()));
-    }
-
-    public Log4jThread(final Runnable target) {
-        super(target, toThreadName(nextThreadNum()));
-    }
-
-    public Log4jThread(final Runnable target, final String name) {
-        super(target, toThreadName(name));
-    }
-
-    public Log4jThread(final String name) {
-        super(toThreadName(name));
-    }
-
-    public Log4jThread(final ThreadGroup group, final Runnable target) {
-        super(group, target, toThreadName(nextThreadNum()));
-    }
-
-    public Log4jThread(final ThreadGroup group, final Runnable target, final String name) {
-        super(group, target, toThreadName(name));
-    }
-
-    public Log4jThread(final ThreadGroup group, final Runnable target, final String name, final long stackSize) {
-        super(group, target, toThreadName(name), stackSize);
-    }
-
-    public Log4jThread(final ThreadGroup group, final String name) {
-        super(group, toThreadName(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.log4j.core.util;
+
+/**
+ * Prefixes thread names with {@code "Log4j2-"}.
+ */
+public class Log4jThread extends Thread {
+
+    static final String PREFIX = "Log4j2-";
+
+    private static int threadInitNumber;
+
+    private static synchronized int nextThreadNum() {
+        return threadInitNumber++;
+    }
+
+    private static String toThreadName(final Object name) {
+        return PREFIX + name;
+    }
+
+    public Log4jThread() {
+        super(toThreadName(nextThreadNum()));
+    }
+
+    public Log4jThread(final Runnable target) {
+        super(target, toThreadName(nextThreadNum()));
+    }
+
+    public Log4jThread(final Runnable target, final String name) {
+        super(target, toThreadName(name));
+    }
+
+    public Log4jThread(final String name) {
+        super(toThreadName(name));
+    }
+
+    public Log4jThread(final ThreadGroup group, final Runnable target) {
+        super(group, target, toThreadName(nextThreadNum()));
+    }
+
+    public Log4jThread(final ThreadGroup group, final Runnable target, final String name) {
+        super(group, target, toThreadName(name));
+    }
+
+    public Log4jThread(final ThreadGroup group, final Runnable target, final String name, final long stackSize) {
+        super(group, target, toThreadName(name), stackSize);
+    }
+
+    public Log4jThread(final ThreadGroup group, final String name) {
+        super(group, toThreadName(name));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
new file mode 100644
index 0000000..ed07056
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
@@ -0,0 +1,90 @@
+/*
+ * 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.util;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.logging.log4j.util.Strings;
+
+/**
+ * Creates {@link Log4jThreads}.
+ * 
+ * @since 2.7
+ */
+public class Log4jThreadFactory implements ThreadFactory {
+
+    private static final String PREFIX = Log4jThread.PREFIX + "TF-";
+
+    /**
+     * Creates a new daemon thread factory.
+     * 
+     * @param threadNamePrefix
+     *            The thread name prefix.
+     * @return a new daemon thread factory.
+     */
+    public static Log4jThreadFactory createDaemonThreadFactory(final String threadNamePrefix) {
+        return new Log4jThreadFactory(threadNamePrefix, true, Thread.NORM_PRIORITY);
+    }
+
+    private static final AtomicInteger FACTORY_NUMBER = new AtomicInteger(1);
+    private static final AtomicInteger THREAD_NUMBER = new AtomicInteger(1);
+    private final boolean daemon;
+    private final ThreadGroup group;
+    private final int priority;
+    private final String threadNamePrefix;
+
+    /**
+     * Constructs a thread factory with default settings.
+     */
+    public Log4jThreadFactory() {
+        this("thread", false, Thread.NORM_PRIORITY);
+    }
+
+    /**
+     * Constructs an initialized thread factory.
+     * 
+     * @param threadNamePrefix
+     *            The thread name prefix.
+     * @param daemon
+     *            Whether to create daemon threads.
+     * @param priority
+     *            The thread priority.
+     */
+    public Log4jThreadFactory(final String threadNamePrefix, final boolean daemon, final int priority) {
+        this.threadNamePrefix = PREFIX + FACTORY_NUMBER.getAndIncrement() + "-" + threadNamePrefix + "-";
+        this.daemon = daemon;
+        this.priority = priority;
+        final SecurityManager securityManager = System.getSecurityManager();
+        this.group = securityManager != null ? securityManager.getThreadGroup()
+                : Thread.currentThread().getThreadGroup();
+    }
+
+    @Override
+    public Thread newThread(final Runnable runnable) {
+        final Thread thread = new Log4jThread(group, runnable, threadNamePrefix + THREAD_NUMBER.getAndIncrement(), 0);
+        if (thread.isDaemon() != daemon) {
+            thread.setDaemon(daemon);
+        }
+        if (thread.getPriority() != priority) {
+            thread.setPriority(priority);
+        }
+        return thread;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9afe7ea8/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
----------------------------------------------------------------------
diff --git a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
index daf6fdd..a76065a 100644
--- a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
+++ b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
@@ -46,6 +46,7 @@ import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
 import org.apache.logging.log4j.core.config.plugins.util.PluginType;
 import org.apache.logging.log4j.core.util.FileUtils;
 import org.apache.logging.log4j.core.util.Log4jThread;
+import org.apache.logging.log4j.core.util.Log4jThreadFactory;
 import org.apache.logging.log4j.core.util.SecretKeyProvider;
 import org.apache.logging.log4j.util.Strings;
 
@@ -124,7 +125,7 @@ public class FlumePersistentManager extends FlumeAvroManager {
             lockTimeoutRetryCount);
         this.worker.start();
         this.secretKey = secretKey;
-        this.threadPool = Executors.newCachedThreadPool(new DaemonThreadFactory());
+        this.threadPool = Executors.newCachedThreadPool(Log4jThreadFactory.createDaemonThreadFactory("Flume"));
         this.lockTimeoutRetryCount = lockTimeoutRetryCount;
     }
 
@@ -824,33 +825,6 @@ public class FlumePersistentManager extends FlumeAvroManager {
     }
 
     /**
-     * Factory that creates Daemon threads that can be properly shut down.
-     */
-    private static class DaemonThreadFactory implements ThreadFactory {
-        private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1);
-        private final ThreadGroup group;
-        private final AtomicInteger threadNumber = new AtomicInteger(1);
-        private final String namePrefix;
-
-        public DaemonThreadFactory() {
-            final SecurityManager securityManager = System.getSecurityManager();
-            group = securityManager != null ? securityManager.getThreadGroup() :
-                Thread.currentThread().getThreadGroup();
-            namePrefix = "DaemonPool-" + POOL_NUMBER.getAndIncrement() + "-thread-";
-        }
-
-        @Override
-        public Thread newThread(final Runnable r) {
-            final Thread thread = new Log4jThread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
-            thread.setDaemon(true);
-            if (thread.getPriority() != Thread.NORM_PRIORITY) {
-                thread.setPriority(Thread.NORM_PRIORITY);
-            }
-            return thread;
-        }
-    }
-
-    /**
      * An internal class.
      */
     private static class Gate {


[12/23] logging-log4j2 git commit: [OG4J2-1501] FileAppender should be able to create files on-demand. Keep in AB order.

Posted by rp...@apache.org.
[OG4J2-1501] FileAppender should be able to create files on-demand. Keep
in AB order.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/03fe13f2
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/03fe13f2
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/03fe13f2

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 03fe13f26ad8a315aabc56bce3e953783d988050
Parents: 2f34ba3
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 22:31:45 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 22:31:45 2016 -0700

----------------------------------------------------------------------
 src/site/xdoc/manual/appenders.xml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/03fe13f2/src/site/xdoc/manual/appenders.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml
index 5df7d99..0a38f0b 100644
--- a/src/site/xdoc/manual/appenders.xml
+++ b/src/site/xdoc/manual/appenders.xml
@@ -353,6 +353,12 @@
               <td>When bufferedIO is true, this is the buffer size, the default is 8192 bytes.</td>
             </tr>
             <tr>
+              <td>createOnDemand</td>
+              <td>boolean</td>
+              <td>The appender creates the file on-demand. The appender only creates the file when a log event 
+                passes all filters and is routed to this appender.</td>
+            </tr>
+            <tr>
               <td>filter</td>
               <td>Filter</td>
               <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
@@ -384,12 +390,6 @@
                 of "%m%n" will be used.</td>
             </tr>
             <tr>
-              <td>createOnDemand</td>
-              <td>boolean</td>
-              <td>The appender creates the file on-demand. The appender only creates the file when a log event 
-                passes all filters and is routed to this appender.</td>
-            </tr>
-            <tr>
               <td>locking</td>
               <td>boolean</td>
               <td>When set to true, I/O operations will occur only while the file lock is held allowing FileAppenders


[10/23] logging-log4j2 git commit: [OG4J2-1501] ileAppender should be able to create files on-demand.

Posted by rp...@apache.org.
[OG4J2-1501] ileAppender should be able to create files on-demand.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/779e542f
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/779e542f
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/779e542f

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 779e542f7c3bddfc54bf48668b0a74ad5120dd7f
Parents: 1967ac1
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 22:29:26 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 22:29:26 2016 -0700

----------------------------------------------------------------------
 src/site/xdoc/manual/appenders.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/779e542f/src/site/xdoc/manual/appenders.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml
index 7263116..7166087 100644
--- a/src/site/xdoc/manual/appenders.xml
+++ b/src/site/xdoc/manual/appenders.xml
@@ -384,7 +384,7 @@
                 of "%m%n" will be used.</td>
             </tr>
             <tr>
-              <td>lazyCreate</td>
+              <td>createOnDemand</td>
               <td>boolean</td>
               <td>The appender creates the file on-demand. The appender only creates the file when a log event 
                 passes all filters and is routed to this appender.</td>


[09/23] logging-log4j2 git commit: Add @SuppressWarnings.

Posted by rp...@apache.org.
Add @SuppressWarnings.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1967ac15
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1967ac15
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1967ac15

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 1967ac1575f3249814649842968e1ef839762815
Parents: f89e975
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 17:37:04 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 17:37:04 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/logging/log4j/core/LoggerContext.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1967ac15/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
index 63073e6..cfb4945 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
@@ -259,6 +259,7 @@ public class LoggerContext extends AbstractLifeCycle
                     this.shutdownCallback = ((ShutdownCallbackRegistry) factory).addShutdownCallback(new Runnable() {
                         @Override
                         public void run() {
+                            @SuppressWarnings("resource")
                             final LoggerContext context = LoggerContext.this;
                             LOGGER.debug(SHUTDOWN_HOOK_MARKER, "Stopping LoggerContext[name={}, {}]",
                                     context.getName(), context);


[22/23] logging-log4j2 git commit: Format nit.

Posted by rp...@apache.org.
Format nit.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e706a22d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e706a22d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e706a22d

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: e706a22da547367910b84c4ec610ae965d0fe50f
Parents: ee6d45f
Author: Gary Gregory <gg...@apache.org>
Authored: Sun Aug 21 11:47:39 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Aug 21 11:47:39 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/junit/LoggerContextRule.java     | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e706a22d/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
index c9b07aa..697e119 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
@@ -45,9 +45,7 @@ public class LoggerContextRule implements TestRule {
     private static final String SYS_PROP_KEY_DISPLAY_NAME = "org.apache.logging.log4j.junit.LoggerContextRule#DisplayName";
     private final String configLocation;
     private LoggerContext context;
-
     private Class<? extends ContextSelector> contextSelectorClass;
-
     private String testClassName;
 
     /**


[08/23] logging-log4j2 git commit: Javadoc: Add missing tags.

Posted by rp...@apache.org.
Javadoc: Add missing tags.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f89e9757
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f89e9757
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f89e9757

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: f89e9757ab5e54a42ce08e8533f3f94cf58b6b4e
Parents: 9bc3195
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 17:35:29 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 17:35:29 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/Logger.java   | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f89e9757/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java b/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
index 030c0a6..d38af94 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
@@ -2713,6 +2713,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2722,6 +2723,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2732,6 +2734,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2743,6 +2746,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2755,6 +2759,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2768,6 +2773,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2782,6 +2788,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2798,6 +2805,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2815,6 +2823,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2833,6 +2842,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param marker the marker data specific to this log statement
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
@@ -2852,6 +2862,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      */
@@ -2860,6 +2871,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2869,6 +2881,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2879,6 +2892,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2890,6 +2904,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2902,6 +2917,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2915,6 +2931,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2929,6 +2946,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2944,6 +2962,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.
@@ -2961,6 +2980,7 @@ public interface Logger {
     /**
      * Logs a message with parameters at the specified level.
      *
+     * @param level the logging level
      * @param message the message to log; the format depends on the message factory.
      * @param p0 parameter to the message.
      * @param p1 parameter to the message.


[19/23] logging-log4j2 git commit: Use status logger to note exception while closing.

Posted by rp...@apache.org.
Use status logger to note exception while closing.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/615c0f84
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/615c0f84
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/615c0f84

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 615c0f8494e7a6fc6f9e689c8272a3474f79f6f6
Parents: 03fe13f
Author: Gary Gregory <gg...@apache.org>
Authored: Sun Aug 21 11:38:00 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Aug 21 11:38:00 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/core/net/server/JmsServer.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/615c0f84/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
index 98d1003..047511e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
@@ -100,7 +100,8 @@ public class JmsServer extends LogEventListener implements MessageListener, Life
     public void stop() {
         try {
             messageConsumer.close();
-        } catch (final JMSException ignored) {
+        } catch (final JMSException e) {
+            LOGGER.debug("Exception closing {}", messageConsumer, e);
         }
         jmsManager.release();
     }


[17/23] logging-log4j2 git commit: Fix CustomLevel in ConfigurationBuilder

Posted by rp...@apache.org.
Fix CustomLevel in ConfigurationBuilder


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f7298ce5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f7298ce5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f7298ce5

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: f7298ce5999588973fbbf1d602ff4777acd3cbc6
Parents: 520170c
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Sun Aug 21 19:13:30 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Sun Aug 21 19:13:30 2016 +0200

----------------------------------------------------------------------
 .../builder/impl/DefaultCustomLevelComponentBuilder.java     | 2 +-
 .../core/config/builder/ConfigurationAssemblerTest.java      | 8 ++++++++
 .../core/config/builder/CustomConfigurationFactory.java      | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f7298ce5/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java
index 4ef25e6..d3c86f5 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java
@@ -28,6 +28,6 @@ class DefaultCustomLevelComponentBuilder extends DefaultComponentAndConfiguratio
     public DefaultCustomLevelComponentBuilder(final DefaultConfigurationBuilder<? extends Configuration> builder,
             final String name, final int level) {
         super(builder, name, "CustomLevel");
-        addAttribute("level", Integer.toString(level));
+        addAttribute("intLevel", level);
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f7298ce5/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
index 61ce701..f9e2d2d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.List;
 import java.util.Map;
 
 import org.apache.logging.log4j.LogManager;
@@ -32,6 +33,7 @@ import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.config.Configurator;
+import org.apache.logging.log4j.core.config.CustomLevelConfig;
 import org.apache.logging.log4j.core.config.LoggerConfig;
 import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
 import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
@@ -81,6 +83,12 @@ public class ConfigurationAssemblerTest {
         final Filter filter = config.getFilter();
         assertNotNull("No Filter", filter);
         assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
+        final List<CustomLevelConfig> customLevels = config.getCustomLevels();
+        assertNotNull("No CustomLevels", filter);
+        assertEquals(1, customLevels.size());
+        CustomLevelConfig customLevel = customLevels.get(0);
+        assertEquals("Panic", customLevel.getLevelName());
+        assertEquals(17, customLevel.getIntLevel());
         final Logger logger = LogManager.getLogger(getClass());
         logger.info("Welcome to Log4j!");
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f7298ce5/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
index cd65bfb..519888c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
@@ -52,6 +52,7 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
                 add(builder.newAppenderRef("Stdout")).
                 addAttribute("additivity", false));
         builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout")));
+        builder.add(builder.newCustomLevel("Panic", 17));
         return builder.build();
     }
 


[07/23] logging-log4j2 git commit: Comment empty blocks.

Posted by rp...@apache.org.
Comment empty blocks.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9bc3195a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9bc3195a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9bc3195a

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 9bc3195a99a55c0d6bdcac70c06abbbff2fb1d6c
Parents: f1b61bd
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 17:33:16 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 17:33:16 2016 -0700

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/appender/AbstractManager.java    | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9bc3195a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
index 9c67f24..4c78e7f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
@@ -87,6 +87,7 @@ public abstract class AbstractManager {
     }
 
     public void updateData(final Object data) {
+        // This default implementation does nothing.
     }
 
     /**
@@ -108,6 +109,7 @@ public abstract class AbstractManager {
      * lock is held.
      */
     protected void releaseSub() {
+        // This default implementation does nothing.
     }
 
     protected int getCount() {


[11/23] logging-log4j2 git commit: [LOG4J2-1504] RollingFileAppender should be able to create files on-demand.

Posted by rp...@apache.org.
[LOG4J2-1504] RollingFileAppender should be able to create files
on-demand.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2f34ba31
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2f34ba31
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2f34ba31

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 2f34ba3112798868b4c6f1ba48a2bcbd922cb8c1
Parents: 779e542
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 20 22:30:41 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 20 22:30:41 2016 -0700

----------------------------------------------------------------------
 src/site/xdoc/manual/appenders.xml | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2f34ba31/src/site/xdoc/manual/appenders.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml
index 7166087..5df7d99 100644
--- a/src/site/xdoc/manual/appenders.xml
+++ b/src/site/xdoc/manual/appenders.xml
@@ -2131,6 +2131,12 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity {
               <td>When bufferedIO is true, this is the buffer size, the default is 8192 bytes.</td>
             </tr>
             <tr>
+              <td>createOnDemand</td>
+              <td>boolean</td>
+              <td>The appender creates the file on-demand. The appender only creates the file when a log event 
+                passes all filters and is routed to this appender.</td>
+            </tr>
+            <tr>
               <td>filter</td>
               <td>Filter</td>
               <td>A Filter to determine if the event should be handled by this Appender. More than one Filter


[13/23] logging-log4j2 git commit: Convert Log4j 1 pattern so it works properly in Log4j 2

Posted by rp...@apache.org.
Convert Log4j 1 pattern so it works properly in Log4j 2


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/71f0762d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/71f0762d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/71f0762d

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 71f0762d232d553afee91c99b46122b87e5e6be7
Parents: 03fe13f
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Sun Aug 21 11:16:20 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Sun Aug 21 11:16:20 2016 +0200

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      | 20 +++++++++++---------
 ...g4j-console-EnhancedPatternLayout.properties |  2 +-
 2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/71f0762d/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
index 74563a5..7fbb729 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
@@ -104,17 +104,19 @@ public class Log4j1ConfigurationFactory extends ConfigurationFactory {
             switch (layoutValue) {
             case "org.apache.log4j.PatternLayout":
             case "org.apache.log4j.EnhancedPatternLayout": {
-                final String pattern = getLog4jAppenderValue(properties, name, "layout.ConversionPattern", null);
+                final String pattern = getLog4jAppenderValue(properties, name, "layout.ConversionPattern", null)
 
-                // Log4j 2's %x (NDC) is not compatible with Log4j 1's %x
-                //   Log4j 1: "foo bar baz"
-                //   Log4j 2: "[foo, bar, baz]"
-                // Use %ndc to get the Log4j 1 format
+                    // Log4j 2's %x (NDC) is not compatible with Log4j 1's %x
+                    //   Log4j 1: "foo bar baz"
+                    //   Log4j 2: "[foo, bar, baz]"
+                    // Use %ndc to get the Log4j 1 format
+                    .replace("%x", "%ndc")
 
-                // Log4j 2's %X (MDC) is not compatible with Log4j 1's %X
-                //   Log4j 1: "{{foo,bar}{hoo,boo}}"
-                //   Log4j 2: "{foo=bar,hoo=boo}"
-                // Use %properties to get the Log4j 1 format
+                    // Log4j 2's %X (MDC) is not compatible with Log4j 1's %X
+                    //   Log4j 1: "{{foo,bar}{hoo,boo}}"
+                    //   Log4j 2: "{foo=bar,hoo=boo}"
+                    // Use %properties to get the Log4j 1 format
+                    .replace("%X", "%properties");
 
                 appenderBuilder.add(newPatternLayout(builder, pattern));
                 break;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/71f0762d/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
index d8099f6..01a4463 100644
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
@@ -14,6 +14,6 @@ log4j.appender.Console=org.apache.log4j.ConsoleAppender
 log4j.appender.Console.ImmediateFlush=false
 log4j.appender.Console.Target=System.err
 log4j.appender.Console.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.Console.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p %properties %ndc: %m%n
+log4j.appender.Console.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p %X %x: %m%n
 
 log4j.logger.com.example.foo = DEBUG


[18/23] logging-log4j2 git commit: Fix includeLocation on Loggers in ConfigurationBuilder

Posted by rp...@apache.org.
Fix includeLocation on Loggers in ConfigurationBuilder


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e73d9d45
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e73d9d45
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e73d9d45

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: e73d9d456e219735a915d40be70ab4cf2b1d7670
Parents: f7298ce
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Sun Aug 21 20:13:40 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Sun Aug 21 20:13:40 2016 +0200

----------------------------------------------------------------------
 .../impl/DefaultConfigurationBuilder.java       | 16 ++++++------
 .../builder/ConfigurationAssemblerTest.java     | 27 ++++++++++++++++----
 .../builder/CustomConfigurationFactory.java     |  6 ++---
 3 files changed, 33 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e73d9d45/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
index 38b4fdb..b455100 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
@@ -215,7 +215,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public LoggerComponentBuilder newAsyncLogger(final String name, final Level level) {
-        return new DefaultLoggerComponentBuilder(this, name, level.toString(), "AsyncLogger", false);
+        return new DefaultLoggerComponentBuilder(this, name, level.toString(), "AsyncLogger");
     }
 
     @Override
@@ -225,7 +225,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public LoggerComponentBuilder newAsyncLogger(final String name, final String level) {
-        return new DefaultLoggerComponentBuilder(this, name, level, "AsyncLogger", false);
+        return new DefaultLoggerComponentBuilder(this, name, level, "AsyncLogger");
     }
 
     @Override
@@ -235,7 +235,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public RootLoggerComponentBuilder newAsyncRootLogger(final Level level) {
-        return new DefaultRootLoggerComponentBuilder(this, level.toString(), "AsyncRoot", false);
+        return new DefaultRootLoggerComponentBuilder(this, level.toString(), "AsyncRoot");
     }
 
     @Override
@@ -245,7 +245,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public RootLoggerComponentBuilder newAsyncRootLogger(final String level) {
-        return new DefaultRootLoggerComponentBuilder(this, level, "AsyncRoot", false);
+        return new DefaultRootLoggerComponentBuilder(this, level, "AsyncRoot");
     }
 
     @Override
@@ -295,7 +295,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public LoggerComponentBuilder newLogger(final String name, final Level level) {
-        return new DefaultLoggerComponentBuilder(this, name, level.toString(), true);
+        return new DefaultLoggerComponentBuilder(this, name, level.toString());
     }
 
     @Override
@@ -305,7 +305,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public LoggerComponentBuilder newLogger(final String name, final String level) {
-        return new DefaultLoggerComponentBuilder(this, name, level, true);
+        return new DefaultLoggerComponentBuilder(this, name, level);
     }
 
     @Override
@@ -315,7 +315,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public RootLoggerComponentBuilder newRootLogger(final Level level) {
-        return new DefaultRootLoggerComponentBuilder(this, level.toString(), true);
+        return new DefaultRootLoggerComponentBuilder(this, level.toString());
     }
 
     @Override
@@ -325,7 +325,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     @Override
     public RootLoggerComponentBuilder newRootLogger(final String level) {
-        return new DefaultRootLoggerComponentBuilder(this, level, true);
+        return new DefaultRootLoggerComponentBuilder(this, level);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e73d9d45/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
index f9e2d2d..ed59a2b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.Appender;
@@ -39,6 +40,7 @@ import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
 import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
 import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
 import org.apache.logging.log4j.core.filter.ThresholdFilter;
+import org.apache.logging.log4j.core.util.Constants;
 import org.junit.Test;
 
 /**
@@ -48,11 +50,17 @@ public class ConfigurationAssemblerTest {
 
     @Test
     public void testBuildConfiguration() throws Exception {
-        final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
-        CustomConfigurationFactory.addTestFixtures("config name", builder);
-        final Configuration configuration = builder.build();
-        try (LoggerContext ctx = Configurator.initialize(configuration)) {
-            validate(configuration);
+        try {
+            System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR,
+                    "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
+            final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
+            CustomConfigurationFactory.addTestFixtures("config name", builder);
+            final Configuration configuration = builder.build();
+            try (LoggerContext ctx = Configurator.initialize(configuration)) {
+                validate(configuration);
+            }
+        } finally {
+            System.getProperties().remove(Constants.LOG4J_CONTEXT_SELECTOR);
         }
     }
 
@@ -61,9 +69,12 @@ public class ConfigurationAssemblerTest {
         try {
             System.setProperty(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY,
                     "org.apache.logging.log4j.core.config.builder.CustomConfigurationFactory");
+            System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR,
+                    "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
             final Configuration config = ((LoggerContext) LogManager.getContext(false)).getConfiguration();
             validate(config);
         } finally {
+            System.getProperties().remove(Constants.LOG4J_CONTEXT_SELECTOR);
             System.getProperties().remove(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY);
         }
     }
@@ -80,6 +91,12 @@ public class ConfigurationAssemblerTest {
         final Map<String, LoggerConfig> loggers = config.getLoggers();
         assertNotNull(loggers);
         assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
+        LoggerConfig rootLoggerConfig = loggers.get("");
+        assertEquals(Level.ERROR, rootLoggerConfig.getLevel());
+        assertFalse(rootLoggerConfig.isIncludeLocation());
+        LoggerConfig loggerConfig = loggers.get("org.apache.logging.log4j");
+        assertEquals(Level.DEBUG, loggerConfig.getLevel());
+        assertTrue(loggerConfig.isIncludeLocation());
         final Filter filter = config.getFilter();
         assertNotNull("No Filter", filter);
         assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e73d9d45/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
index 519888c..d68b40f 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
@@ -48,9 +48,9 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
         appenderBuilder.add(builder.newFilter("MarkerFilter", Filter.Result.DENY,
                 Filter.Result.NEUTRAL).addAttribute("marker", "FLOW"));
         builder.add(appenderBuilder);
-        builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG).
-                add(builder.newAppenderRef("Stdout")).
-                addAttribute("additivity", false));
+        builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG, true).
+                    add(builder.newAppenderRef("Stdout")).
+                    addAttribute("additivity", false));
         builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout")));
         builder.add(builder.newCustomLevel("Panic", 17));
         return builder.build();


[02/23] logging-log4j2 git commit: Fix TTCC constant

Posted by rp...@apache.org.
Fix TTCC constant


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/5aac1af7
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/5aac1af7
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/5aac1af7

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 5aac1af72d826b654f6e4f4b80cb65f90f39458d
Parents: 932824a
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Sat Aug 20 20:29:53 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Sat Aug 20 20:29:53 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/core/layout/PatternLayout.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/5aac1af7/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
index 4f77649..2c235f4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
@@ -64,9 +64,9 @@ public final class PatternLayout extends AbstractStringLayout {
     public static final String DEFAULT_CONVERSION_PATTERN = "%m%n";
 
     /**
-     * A conversion pattern equivalent to the TTCCCLayout. Current value is <b>%r [%t] %p %c %x - %m%n</b>.
+     * A conversion pattern equivalent to the TTCCLayout. Current value is <b>%r [%t] %p %c %notEmpty{%x }- %m%n</b>.
      */
-    public static final String TTCC_CONVERSION_PATTERN = "%r [%t] %p %c %x - %m%n";
+    public static final String TTCC_CONVERSION_PATTERN = "%r [%t] %p %c %notEmpty{%x }- %m%n";
 
     /**
      * A simple pattern. Current value is <b>%d [%t] %p %c - %m%n</b>.


[15/23] logging-log4j2 git commit: Close input stream when done

Posted by rp...@apache.org.
Close input stream when done


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a85fe0c7
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a85fe0c7
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a85fe0c7

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: a85fe0c73ef5d145892937f105b4b0d61e270079
Parents: 74da11e
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Sun Aug 21 12:36:46 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Sun Aug 21 12:36:46 2016 +0200

----------------------------------------------------------------------
 .../org/apache/log4j/config/Log4j1ConfigurationFactory.java     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a85fe0c7/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
index 2ca2ac1..b1b2dfe 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
 import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
 
 import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * Experimental ConfigurationFactory for Log4j 1.2 properties configuration files.
@@ -40,8 +41,8 @@ public class Log4j1ConfigurationFactory extends ConfigurationFactory {
     @Override
     public Configuration getConfiguration(final ConfigurationSource source) {
         final ConfigurationBuilder<BuiltConfiguration> builder;
-        try {
-            builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(source.getInputStream());
+        try (final InputStream configStream = source.getInputStream()) {
+            builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(configStream);
         } catch (IOException e) {
             throw new ConfigurationException("Unable to load " + source.toString(), e);
         }


[14/23] logging-log4j2 git commit: Split Log4j1 config factory into tiny factory and separate parser

Posted by rp...@apache.org.
Split Log4j1 config factory into tiny factory and separate parser


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/74da11ee
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/74da11ee
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/74da11ee

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 74da11ee8b2ce39925b16dd89c846be18c1b9e0f
Parents: 71f0762
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Sun Aug 21 12:03:01 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Sun Aug 21 12:05:37 2016 +0200

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      | 311 +------------------
 .../log4j/config/Log4j1ConfigurationParser.java | 301 ++++++++++++++++++
 2 files changed, 313 insertions(+), 299 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/74da11ee/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
index 7fbb729..2ca2ac1 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
@@ -16,45 +16,17 @@
  */
 package org.apache.log4j.config;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.appender.ConsoleAppender.Target;
 import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationException;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
 import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
-import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
-import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
 import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
-import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
 
 /**
- * Experimental ConfigurationFactory for Log4j 1.2 properties files.
- * <p>
- * Currently supports:
- * </p>
- * <ul>
- * <li>log4j.debug</li>
- * <li>log4j.rootLogger</li>
- * <li>log4j.logger</li>
- * <li>log4j.appender</li>
- * <li>org.apache.log4j.ConsoleAppender</li>
- * <ul>
- * <li>Follow</li>
- * <li>Target</li>
- * <li>layout</li>
- * </ul>
- * </ul>
+ * Experimental ConfigurationFactory for Log4j 1.2 properties configuration files.
  */
 // TODO
 // @Plugin(name = "Log4j1ConfigurationFactory", category = ConfigurationFactory.CATEGORY)
@@ -63,282 +35,23 @@ import org.apache.logging.log4j.status.StatusLogger;
 // @Order(50)
 public class Log4j1ConfigurationFactory extends ConfigurationFactory {
 
-    private Map<String, String> buildClassToPropertyPrefixMap(final Properties properties,
-            final String[] sortedAppenderNames) {
-        final String prefix = "log4j.appender.";
-        final int preLength = prefix.length();
-        final Map<String, String> map = new HashMap<>(sortedAppenderNames.length);
-        for (final Entry<Object, Object> entry : properties.entrySet()) {
-            final Object keyObj = entry.getKey();
-            if (keyObj != null) {
-                final String key = keyObj.toString();
-                if (key.startsWith(prefix)) {
-                    if (key.indexOf('.', preLength) < 0) {
-                        final String name = key.substring(preLength);
-                        if (Arrays.binarySearch(sortedAppenderNames, name) >= 0) {
-                            final Object value = entry.getValue();
-                            if (value != null) {
-                                map.put(name, value.toString());
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return map;
-    }
-
-    private void buildConsoleAppender(final Properties properties, final String name,
-            final ConfigurationBuilder<BuiltConfiguration> builder) {
-        final AppenderComponentBuilder appenderBuilder = builder.newAppender(name, "Console");
-        buildConsoleAppenderTarget(properties, name, builder, appenderBuilder);
-        buildAppenderLayout(properties, name, builder, appenderBuilder);
-        buildConsoleAppenderFollow(properties, name, builder, appenderBuilder);
-        builder.add(appenderBuilder);
-    }
-
-    private void buildAppenderLayout(final Properties properties, final String name,
-            final ConfigurationBuilder<BuiltConfiguration> builder, final AppenderComponentBuilder appenderBuilder) {
-        final String layoutValue = getLog4jAppenderValue(properties, name, "layout", null);
-        if (layoutValue != null) {
-            switch (layoutValue) {
-            case "org.apache.log4j.PatternLayout":
-            case "org.apache.log4j.EnhancedPatternLayout": {
-                final String pattern = getLog4jAppenderValue(properties, name, "layout.ConversionPattern", null)
-
-                    // Log4j 2's %x (NDC) is not compatible with Log4j 1's %x
-                    //   Log4j 1: "foo bar baz"
-                    //   Log4j 2: "[foo, bar, baz]"
-                    // Use %ndc to get the Log4j 1 format
-                    .replace("%x", "%ndc")
-
-                    // Log4j 2's %X (MDC) is not compatible with Log4j 1's %X
-                    //   Log4j 1: "{{foo,bar}{hoo,boo}}"
-                    //   Log4j 2: "{foo=bar,hoo=boo}"
-                    // Use %properties to get the Log4j 1 format
-                    .replace("%X", "%properties");
-
-                appenderBuilder.add(newPatternLayout(builder, pattern));
-                break;
-            }
-            case "org.apache.log4j.SimpleLayout": {
-                appenderBuilder.add(newPatternLayout(builder, "%level - %m%n"));
-                break;
-            }
-            case "org.apache.log4j.TTCCLayout": {
-                String pattern = "%r ";
-                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.ThreadPrinting", "true"))) {
-                    pattern += "[%t] ";
-                }
-                pattern += "%p ";
-                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.CategoryPrefixing", "true"))) {
-                    pattern += "%c ";
-                }
-                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.ContextPrinting", "true"))) {
-                    pattern += "%notEmpty{%ndc }";
-                }
-                pattern += "- %m%n";
-                appenderBuilder.add(newPatternLayout(builder, pattern));
-                break;
-            }
-            case "org.apache.log4j.HTMLLayout": {
-                LayoutComponentBuilder htmlLayout = builder.newLayout("HtmlLayout");
-                htmlLayout.addAttribute("title",
-                        getLog4jAppenderValue(properties, name, "layout.Title", "Log4J Log Messages"));
-                htmlLayout.addAttribute("locationInfo",
-                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.LocationInfo", "false")));
-                appenderBuilder.add(htmlLayout);
-                break;
-            }
-            case "org.apache.log4j.xml.XMLLayout": {
-                LayoutComponentBuilder xmlLayout = builder.newLayout("Log4j1XmlLayout");
-                xmlLayout.addAttribute("locationInfo",
-                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.LocationInfo", "false")));
-                xmlLayout.addAttribute("properties",
-                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.Properties", "false")));
-                appenderBuilder.add(xmlLayout);
-                break;
-            }
-            default:
-                reportWarning("Unsupported layout: " + layoutValue);
-            }
-        }
-    }
-
-    private LayoutComponentBuilder newPatternLayout(final ConfigurationBuilder<BuiltConfiguration> builder,
-            final String pattern) {
-        final LayoutComponentBuilder layoutBuilder = builder.newLayout("PatternLayout");
-        if (pattern != null) {
-            layoutBuilder.addAttribute("pattern", pattern);
-        }
-        return layoutBuilder;
-    }
-
-    private void buildConsoleAppenderTarget(final Properties properties, final String name,
-            final ConfigurationBuilder<BuiltConfiguration> builder, final AppenderComponentBuilder appenderBuilder) {
-        final String value = getLog4jAppenderValue(properties, name, "Target", "System.out");
-        if (value != null) {
-            final Target target;
-            switch (value) {
-            case "System.out":
-                target = ConsoleAppender.Target.SYSTEM_OUT;
-                break;
-            case "System.err":
-                target = ConsoleAppender.Target.SYSTEM_ERR;
-                break;
-            default:
-                reportWarning("Unknow value for console Target: " + value);
-                target = null;
-            }
-            if (target != null) {
-                appenderBuilder.addAttribute("target", target);
-            }
-        }
-    }
-
-    private void buildConsoleAppenderFollow(final Properties properties, final String name,
-            final ConfigurationBuilder<BuiltConfiguration> builder, final AppenderComponentBuilder appenderBuilder) {
-        final String value = getLog4jAppenderValue(properties, name, "Follow", "false");
-        if (value != null) {
-            appenderBuilder.addAttribute("follow", Boolean.valueOf(value).booleanValue());
-        }
-    }
-
-    Configuration createConfiguration(final String configName, final URI configLocation,
-            final ConfigurationBuilder<BuiltConfiguration> builder) throws IOException {
-        builder.setConfigurationName(configName);
-        final Properties properties = load(configLocation);
-        if (properties == null) {
-            return null;
-        }
-        // DEBUG
-        final String debugValue = getLog4jValue(properties, "debug");
-        if (Boolean.valueOf(debugValue)) {
-            builder.setStatusLevel(Level.DEBUG);
-        }
-        // Root
-        final String[] sortedAppenderNamesC = buildRootLogger(builder, getRootCategoryValue(properties));
-        final String[] sortedAppenderNamesL = buildRootLogger(builder, getRootLoggerValue(properties));
-        final String[] sortedAppenderNames = sortedAppenderNamesL.length > 0 ? sortedAppenderNamesL
-                : sortedAppenderNamesC;
-        // Appenders
-        final Map<String, String> classNameToProperty = buildClassToPropertyPrefixMap(properties, sortedAppenderNames);
-        for (final Entry<String, String> entry : classNameToProperty.entrySet()) {
-            final String appenderName = entry.getKey();
-            switch (entry.getValue()) {
-            case "org.apache.log4j.ConsoleAppender":
-                buildConsoleAppender(properties, appenderName, builder);
-                break;
-            default:
-                reportWarning("Ignoring appender " + appenderName
-                        + "; consider porting your configuration file to the current Log4j format.");
-            }
-        }
-        // Loggers
-        buildLoggers(properties, "log4j.category.", builder);
-        buildLoggers(properties, "log4j.logger.", builder);
-        return builder.build();
-    }
-
-    private String[] buildRootLogger(final ConfigurationBuilder<BuiltConfiguration> builder,
-            final String rootLoggerValue) {
-        if (rootLoggerValue == null) {
-            return new String[0];
-        }
-        final String[] rootLoggerParts = rootLoggerValue.split("\\s*,\\s*");
-        final Level rootLoggerLevel = rootLoggerParts.length > 0 ? Level.valueOf(rootLoggerParts[0]) : Level.ERROR;
-        final String[] sortedAppenderNames = Arrays.copyOfRange(rootLoggerParts, 1, rootLoggerParts.length);
-        Arrays.sort(sortedAppenderNames);
-        RootLoggerComponentBuilder loggerBuilder = builder.newRootLogger(rootLoggerLevel);
-        for (String appender : sortedAppenderNames) {
-            loggerBuilder.add(builder.newAppenderRef(appender));
-        }
-        builder.add(loggerBuilder);
-        return sortedAppenderNames;
-    }
-
-    private void buildLoggers(final Properties properties, final String prefix,
-            final ConfigurationBuilder<BuiltConfiguration> builder) {
-        final int preLength = prefix.length();
-        for (final Entry<Object, Object> entry : properties.entrySet()) {
-            final Object keyObj = entry.getKey();
-            if (keyObj != null) {
-                final String key = keyObj.toString();
-                if (key.startsWith(prefix)) {
-                    final String name = key.substring(preLength);
-                    final Object value = entry.getValue();
-                    if (value != null) {
-                        builder.add(builder.newLogger(name, Level.valueOf(value.toString())));
-                    }
-                }
-            }
-        }
-
-    }
+    private static final String[] SUFFIXES = {".properties"};
 
     @Override
     public Configuration getConfiguration(final ConfigurationSource source) {
-        return getConfiguration(source.toString(), null);
-    }
-
-    @Override
-    public Configuration getConfiguration(final String name, final URI configLocation) {
+        final ConfigurationBuilder<BuiltConfiguration> builder;
         try {
-            return createConfiguration(name, configLocation, newConfigurationBuilder());
-        } catch (final IOException e) {
-            StatusLogger.getLogger().error(e);
-            return null;
+            builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(source.getInputStream());
+        } catch (IOException e) {
+            throw new ConfigurationException("Unable to load " + source.toString(), e);
         }
-    }
-
-    private String getLog4jAppenderValue(final Properties properties, final String appenderName,
-            final String attributeName, final String defaultValue) {
-        return properties.getProperty("log4j.appender." + appenderName + "." + attributeName, defaultValue);
-    }
-
-    private String getLog4jValue(final Properties properties, final String key) {
-        return properties.getProperty("log4j." + key);
-    }
-
-    private String getRootCategoryValue(final Properties properties) {
-        return getLog4jValue(properties, "rootCategory");
-    }
-
-    private String getRootLoggerValue(final Properties properties) {
-        return getLog4jValue(properties, "rootLogger");
+        if (builder == null) return null;
+        return builder.build();
     }
 
     @Override
     protected String[] getSupportedTypes() {
-        return new String[] { "*.properties", ".xml" };
-    }
-
-    private Properties load(final URI uri) throws IOException {
-        final Properties properties = toProperties(uri);
-        final String rootCategoryValue = getRootCategoryValue(properties);
-        final String rootLoggerValue = getRootLoggerValue(properties);
-        if (rootCategoryValue == null && rootLoggerValue == null) {
-            // This is not a Log4j 1 properties file.
-            return null;
-        }
-        return properties;
+        return SUFFIXES;
     }
 
-    private void reportWarning(final String msg) {
-        StatusLogger.getLogger().warn("Log4j version 1 to 2 configuration bridge: " + msg);
-
-    }
-
-    private Properties toProperties(final URI uri) throws IOException {
-        final Properties properties;
-        try (InputStream in = uri.toURL().openStream()) {
-            properties = new Properties();
-            if (uri.toString().endsWith(".xml")) {
-                properties.loadFromXML(in);
-            } else {
-                properties.load(in);
-            }
-        }
-        return properties;
-    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/74da11ee/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
new file mode 100644
index 0000000..f98f909
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
@@ -0,0 +1,301 @@
+/*
+ * 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.log4j.config;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.appender.ConsoleAppender;
+import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
+import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Experimental parser for Log4j 1.2 properties configuration files.
+ * <p>
+ * Currently supports:
+ * </p>
+ * <ul>
+ * <li>log4j.debug</li>
+ * <li>log4j.rootLogger</li>
+ * <li>log4j.logger</li>
+ * <li>log4j.appender</li>
+ * <li>org.apache.log4j.ConsoleAppender</li>
+ * <ul>
+ * <li>Follow</li>
+ * <li>Target</li>
+ * <li>layout</li>
+ * </ul>
+ * </ul>
+ */
+public class Log4j1ConfigurationParser {
+
+    /**
+     * 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
+     * @throws IOException  if unable to read the input
+     */
+    public ConfigurationBuilder<BuiltConfiguration> buildConfigurationBuilder(InputStream input) throws IOException {
+        final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
+        builder.setConfigurationName("Log4j1");
+        final Properties properties = new Properties();
+        properties.load(input);
+        final String rootCategoryValue = getRootCategoryValue(properties);
+        final String rootLoggerValue = getRootLoggerValue(properties);
+        if (rootCategoryValue == null && rootLoggerValue == null) {
+            // This is not a Log4j 1 properties configuration file.
+            return null;
+        }
+        // DEBUG
+        final String debugValue = getLog4jValue(properties, "debug");
+        if (Boolean.valueOf(debugValue)) {
+            builder.setStatusLevel(Level.DEBUG);
+        }
+        // Root
+        final String[] sortedAppenderNamesC = buildRootLogger(builder, getRootCategoryValue(properties));
+        final String[] sortedAppenderNamesL = buildRootLogger(builder, getRootLoggerValue(properties));
+        final String[] sortedAppenderNames = sortedAppenderNamesL.length > 0 ? sortedAppenderNamesL
+                : sortedAppenderNamesC;
+        // Appenders
+        final Map<String, String> classNameToProperty = buildClassToPropertyPrefixMap(properties, sortedAppenderNames);
+        for (final Map.Entry<String, String> entry : classNameToProperty.entrySet()) {
+            final String appenderName = entry.getKey();
+            switch (entry.getValue()) {
+            case "org.apache.log4j.ConsoleAppender":
+                buildConsoleAppender(properties, appenderName, builder);
+                break;
+            default:
+                reportWarning("Ignoring appender " + appenderName
+                        + "; consider porting your configuration file to the current Log4j format.");
+            }
+        }
+        // Loggers
+        buildLoggers(properties, "log4j.category.", builder);
+        buildLoggers(properties, "log4j.logger.", builder);
+        return builder;
+    }
+
+    private Map<String, String> buildClassToPropertyPrefixMap(final Properties properties,
+                                                              final String[] sortedAppenderNames) {
+        final String prefix = "log4j.appender.";
+        final int preLength = prefix.length();
+        final Map<String, String> map = new HashMap<>(sortedAppenderNames.length);
+        for (final Map.Entry<Object, Object> entry : properties.entrySet()) {
+            final Object keyObj = entry.getKey();
+            if (keyObj != null) {
+                final String key = keyObj.toString();
+                if (key.startsWith(prefix)) {
+                    if (key.indexOf('.', preLength) < 0) {
+                        final String name = key.substring(preLength);
+                        if (Arrays.binarySearch(sortedAppenderNames, name) >= 0) {
+                            final Object value = entry.getValue();
+                            if (value != null) {
+                                map.put(name, value.toString());
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return map;
+    }
+
+    private void buildConsoleAppender(final Properties properties, final String name,
+            final ConfigurationBuilder<BuiltConfiguration> builder) {
+        final AppenderComponentBuilder appenderBuilder = builder.newAppender(name, "Console");
+        buildConsoleAppenderTarget(properties, name, builder, appenderBuilder);
+        buildAppenderLayout(properties, name, builder, appenderBuilder);
+        buildConsoleAppenderFollow(properties, name, builder, appenderBuilder);
+        builder.add(appenderBuilder);
+    }
+
+    private void buildAppenderLayout(final Properties properties, final String name,
+            final ConfigurationBuilder<BuiltConfiguration> builder, final AppenderComponentBuilder appenderBuilder) {
+        final String layoutValue = getLog4jAppenderValue(properties, name, "layout", null);
+        if (layoutValue != null) {
+            switch (layoutValue) {
+            case "org.apache.log4j.PatternLayout":
+            case "org.apache.log4j.EnhancedPatternLayout": {
+                final String pattern = getLog4jAppenderValue(properties, name, "layout.ConversionPattern", null)
+
+                    // Log4j 2's %x (NDC) is not compatible with Log4j 1's %x
+                    //   Log4j 1: "foo bar baz"
+                    //   Log4j 2: "[foo, bar, baz]"
+                    // Use %ndc to get the Log4j 1 format
+                    .replace("%x", "%ndc")
+
+                    // Log4j 2's %X (MDC) is not compatible with Log4j 1's %X
+                    //   Log4j 1: "{{foo,bar}{hoo,boo}}"
+                    //   Log4j 2: "{foo=bar,hoo=boo}"
+                    // Use %properties to get the Log4j 1 format
+                    .replace("%X", "%properties");
+
+                appenderBuilder.add(newPatternLayout(builder, pattern));
+                break;
+            }
+            case "org.apache.log4j.SimpleLayout": {
+                appenderBuilder.add(newPatternLayout(builder, "%level - %m%n"));
+                break;
+            }
+            case "org.apache.log4j.TTCCLayout": {
+                String pattern = "%r ";
+                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.ThreadPrinting", "true"))) {
+                    pattern += "[%t] ";
+                }
+                pattern += "%p ";
+                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.CategoryPrefixing", "true"))) {
+                    pattern += "%c ";
+                }
+                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.ContextPrinting", "true"))) {
+                    pattern += "%notEmpty{%ndc }";
+                }
+                pattern += "- %m%n";
+                appenderBuilder.add(newPatternLayout(builder, pattern));
+                break;
+            }
+            case "org.apache.log4j.HTMLLayout": {
+                LayoutComponentBuilder htmlLayout = builder.newLayout("HtmlLayout");
+                htmlLayout.addAttribute("title",
+                        getLog4jAppenderValue(properties, name, "layout.Title", "Log4J Log Messages"));
+                htmlLayout.addAttribute("locationInfo",
+                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.LocationInfo", "false")));
+                appenderBuilder.add(htmlLayout);
+                break;
+            }
+            case "org.apache.log4j.xml.XMLLayout": {
+                LayoutComponentBuilder xmlLayout = builder.newLayout("Log4j1XmlLayout");
+                xmlLayout.addAttribute("locationInfo",
+                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.LocationInfo", "false")));
+                xmlLayout.addAttribute("properties",
+                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.Properties", "false")));
+                appenderBuilder.add(xmlLayout);
+                break;
+            }
+            default:
+                reportWarning("Unsupported layout: " + layoutValue);
+            }
+        }
+    }
+
+    private LayoutComponentBuilder newPatternLayout(final ConfigurationBuilder<BuiltConfiguration> builder,
+            final String pattern) {
+        final LayoutComponentBuilder layoutBuilder = builder.newLayout("PatternLayout");
+        if (pattern != null) {
+            layoutBuilder.addAttribute("pattern", pattern);
+        }
+        return layoutBuilder;
+    }
+
+    private void buildConsoleAppenderTarget(final Properties properties, final String name,
+            final ConfigurationBuilder<BuiltConfiguration> builder, final AppenderComponentBuilder appenderBuilder) {
+        final String value = getLog4jAppenderValue(properties, name, "Target", "System.out");
+        if (value != null) {
+            final ConsoleAppender.Target target;
+            switch (value) {
+            case "System.out":
+                target = ConsoleAppender.Target.SYSTEM_OUT;
+                break;
+            case "System.err":
+                target = ConsoleAppender.Target.SYSTEM_ERR;
+                break;
+            default:
+                reportWarning("Unknow value for console Target: " + value);
+                target = null;
+            }
+            if (target != null) {
+                appenderBuilder.addAttribute("target", target);
+            }
+        }
+    }
+
+    private void buildConsoleAppenderFollow(final Properties properties, final String name,
+            final ConfigurationBuilder<BuiltConfiguration> builder, final AppenderComponentBuilder appenderBuilder) {
+        final String value = getLog4jAppenderValue(properties, name, "Follow", "false");
+        if (value != null) {
+            appenderBuilder.addAttribute("follow", Boolean.valueOf(value).booleanValue());
+        }
+    }
+
+    private String[] buildRootLogger(final ConfigurationBuilder<BuiltConfiguration> builder,
+            final String rootLoggerValue) {
+        if (rootLoggerValue == null) {
+            return new String[0];
+        }
+        final String[] rootLoggerParts = rootLoggerValue.split("\\s*,\\s*");
+        final Level rootLoggerLevel = rootLoggerParts.length > 0 ? Level.valueOf(rootLoggerParts[0]) : Level.ERROR;
+        final String[] sortedAppenderNames = Arrays.copyOfRange(rootLoggerParts, 1, rootLoggerParts.length);
+        Arrays.sort(sortedAppenderNames);
+        RootLoggerComponentBuilder loggerBuilder = builder.newRootLogger(rootLoggerLevel);
+        for (String appender : sortedAppenderNames) {
+            loggerBuilder.add(builder.newAppenderRef(appender));
+        }
+        builder.add(loggerBuilder);
+        return sortedAppenderNames;
+    }
+
+    private void buildLoggers(final Properties properties, final String prefix,
+            final ConfigurationBuilder<BuiltConfiguration> builder) {
+        final int preLength = prefix.length();
+        for (final Map.Entry<Object, Object> entry : properties.entrySet()) {
+            final Object keyObj = entry.getKey();
+            if (keyObj != null) {
+                final String key = keyObj.toString();
+                if (key.startsWith(prefix)) {
+                    final String name = key.substring(preLength);
+                    final Object value = entry.getValue();
+                    if (value != null) {
+                        builder.add(builder.newLogger(name, Level.valueOf(value.toString())));
+                    }
+                }
+            }
+        }
+
+    }
+
+    private String getLog4jAppenderValue(final Properties properties, final String appenderName,
+            final String attributeName, final String defaultValue) {
+        return properties.getProperty("log4j.appender." + appenderName + "." + attributeName, defaultValue);
+    }
+
+    private String getLog4jValue(final Properties properties, final String key) {
+        return properties.getProperty("log4j." + key);
+    }
+
+    private String getRootCategoryValue(final Properties properties) {
+        return getLog4jValue(properties, "rootCategory");
+    }
+
+    private String getRootLoggerValue(final Properties properties) {
+        return getLog4jValue(properties, "rootLogger");
+    }
+
+    private void reportWarning(final String msg) {
+        StatusLogger.getLogger().warn("Log4j 1 configuration parser: " + msg);
+    }
+
+}