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/27 06:55:30 UTC

[01/42] logging-log4j2 git commit: Create branch for [LOG4J2-1539].

Repository: logging-log4j2
Updated Branches:
  refs/heads/LOG4J2-1349-gcfree-threadcontext 37d47a62a -> 3832ad9b3


Create branch for [LOG4J2-1539].

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 3f92f7cc11f4f7f9a36784f4bdc5380ebbb27c5c
Parents: 7eba2e9
Author: Gary Gregory <gg...@apache.org>
Authored: Mon Aug 22 16:50:01 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Mon Aug 22 16:50:01 2016 -0700

----------------------------------------------------------------------
 .../logging/log4j/core/AbstractLifeCycle.java   |   8 ++
 .../apache/logging/log4j/core/LifeCycle.java    |  13 +++
 .../logging/log4j/core/LoggerContext.java       | 111 ++++++++++++++++++-
 .../log4j/core/appender/AbstractManager.java    |   6 +
 .../core/appender/mom/kafka/KafkaManager.java   |  17 ++-
 .../appender/rolling/RollingFileManager.java    |  12 +-
 .../core/config/ConfigurationScheduler.java     |   8 +-
 .../core/config/ConfiguratonFileWatcher.java    |  10 +-
 .../logging/log4j/core/config/Configurator.java |  36 +++++-
 .../apache/logging/log4j/core/jmx/Server.java   |   2 +-
 .../log4j/core/net/server/JmsServer.java        |   7 ++
 .../util/DefaultShutdownCallbackRegistry.java   |   7 ++
 .../log4j/core/util/Log4jThreadFactory.java     |  11 ++
 .../RandomRollingAppenderOnStartupTest.java     |   2 +-
 .../rolling/RollingAppenderCronTest.java        |   2 +-
 .../RollingAppenderCustomDeleteActionTest.java  |   2 +-
 ...lingAppenderDeleteAccumulatedCount1Test.java |   2 +-
 ...lingAppenderDeleteAccumulatedCount2Test.java |   2 +-
 ...ollingAppenderDeleteAccumulatedSizeTest.java |   2 +-
 .../RollingAppenderDeleteMaxDepthTest.java      |   2 +-
 .../RollingAppenderDeleteNestedTest.java        |   2 +-
 .../RollingAppenderDeleteScriptFri13thTest.java |   2 +-
 .../RollingAppenderDeleteScriptTest.java        |   2 +-
 ...ollingAppenderNoUnconditionalDeleteTest.java |   2 +-
 .../rolling/RollingAppenderOnStartupTest.java   |   2 +-
 .../rolling/RollingAppenderSizeTest.java        |   2 +-
 .../rolling/RollingAppenderTimeAndSizeTest.java |   4 +-
 .../rolling/RollingAppenderTimeTest.java        |   2 +-
 ...RandomAccessFileManagerHeaderFooterTest.java |   3 +-
 .../logging/log4j/junit/LoggerContextRule.java  |  25 ++++-
 30 files changed, 260 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
index a5a0c77..069362d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
@@ -16,6 +16,8 @@
  */
 package org.apache.logging.log4j.core;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.logging.log4j.status.StatusLogger;
 
 /**
@@ -121,4 +123,10 @@ public class AbstractLifeCycle implements LifeCycle {
         this.state = LifeCycle.State.STOPPED;
     }
 
+    @Override
+    public boolean stop(long timeout, TimeUnit timeUnit) {
+        this.state = LifeCycle.State.STOPPED;
+        return true;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
index 33a61a2..9311487 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
@@ -17,6 +17,8 @@
 
 package org.apache.logging.log4j.core;
 
+import java.util.concurrent.TimeUnit;
+
 /**
  * All proper Java frameworks implement some sort of object life cycle. In Log4j, the main interface for handling
  * the life cycle context of an object is this one. An object first starts in the {@link State#INITIALIZED} state
@@ -60,7 +62,18 @@ public interface LifeCycle {
 
     void stop();
 
+    /**
+     * Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current
+     * thread is interrupted, whichever happens first.
+     * 
+     * @param timeout the maximum time to wait
+     * @param timeUnit the time unit of the timeout argument
+     * @return 
+     */
+    boolean stop(long timeout, TimeUnit timeUnit);
+
     boolean isStarted();
 
     boolean isStopped();
+
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 cfb4945..d1bc137 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
@@ -26,6 +26,11 @@ import java.util.Collection;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -40,6 +45,7 @@ import org.apache.logging.log4j.core.config.Reconfigurable;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.jmx.Server;
 import org.apache.logging.log4j.core.util.Cancellable;
+import org.apache.logging.log4j.core.util.Log4jThreadFactory;
 import org.apache.logging.log4j.core.util.NetUtils;
 import org.apache.logging.log4j.core.util.ShutdownCallbackRegistry;
 import org.apache.logging.log4j.message.MessageFactory;
@@ -72,6 +78,8 @@ public class LoggerContext extends AbstractLifeCycle
      * reference is updated.
      */
     private volatile Configuration configuration = new DefaultConfiguration();
+    private ExecutorService executorService;
+    private ExecutorService executorServiceDeamons;
     private Object externalContext;
     private String contextName;
     private volatile URI configLocation;
@@ -294,11 +302,18 @@ public class LoggerContext extends AbstractLifeCycle
 
     @Override
     public void stop() {
+        stop(0, null);
+    }
+
+    @Override
+    public boolean stop(long timeout, TimeUnit timeUnit) {
         LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
         configLock.lock();
+        final boolean shutdownEs;
+        final boolean shutdownEsd;
         try {
             if (this.isStopped()) {
-                return;
+                return true;
             }
 
             this.setStopping();
@@ -317,11 +332,54 @@ public class LoggerContext extends AbstractLifeCycle
             prev.stop();
             externalContext = null;
             LogManager.getFactory().removeContext(this);
+            shutdownEs = shutdown(executorService, timeout, timeUnit);
+            // Do not wait for daemon threads
+            shutdownEsd = shutdown(executorServiceDeamons, 0, null);
             this.setStopped();
         } finally {
             configLock.unlock();
         }
         LOGGER.debug("Stopped LoggerContext[name={}, {}]...", getName(), this);
+        return shutdownEs && shutdownEsd;
+    }
+
+    /**
+     * Shuts down the given pool.
+     * 
+     * @param pool
+     *            the pool to shutdown.
+     * @param timeout
+     *            the maximum time to wait
+     * @param unit
+     *            the time unit of the timeout argument
+     * @return {@code true} if the given executor terminated and {@code false} if the timeout elapsed before termination.
+     */
+    private boolean shutdown(ExecutorService pool, long timeout, TimeUnit timeUnit) {
+        pool.shutdown(); // Disable new tasks from being submitted
+        if (timeout > 0 && timeUnit == null) {
+            throw new IllegalArgumentException(
+                    String.format("Logger context '%s' can't shutdown %s when timeout = %,d and timeUnit = %s.",
+                            getName(), pool, timeout, timeUnit));
+        }
+        if (timeout > 0) {
+            try {
+                // Wait a while for existing tasks to terminate
+                if (!pool.awaitTermination(timeout, timeUnit)) {
+                    pool.shutdownNow(); // Cancel currently executing tasks
+                    // Wait a while for tasks to respond to being cancelled
+                    if (!pool.awaitTermination(timeout, timeUnit)) {
+                        LOGGER.error("LoggerContext '{}' pool {} did not terminate after {} {}", getName(), pool, timeout, timeUnit);
+                    }
+                    return false;
+                }
+            } catch (InterruptedException ie) {
+                // (Re-)Cancel if current thread also interrupted
+                pool.shutdownNow();
+                // Preserve interrupt status
+                Thread.currentThread().interrupt();
+            }
+        }
+        return true;
     }
 
     /**
@@ -490,6 +548,9 @@ public class LoggerContext extends AbstractLifeCycle
         try {
             final Configuration prev = this.configuration;
             config.addListener(this);
+            executorService = Executors.newCachedThreadPool(Log4jThreadFactory.createThreadFactory(contextName));
+            executorServiceDeamons = Executors.newCachedThreadPool(Log4jThreadFactory.createDaemonThreadFactory(contextName));
+
             final ConcurrentMap<String, String> map = config.getComponent(Configuration.CONTEXT_PROPERTIES);
 
             try { // LOG4J2-719 network access may throw android.os.NetworkOnMainThreadException
@@ -630,4 +691,52 @@ public class LoggerContext extends AbstractLifeCycle
         return new Logger(ctx, name, messageFactory);
     }
 
+    /**
+     * Gets the executor service to submit normal tasks.
+     *  
+     * @return the ExecutorService to submit normal tasks.
+     */
+    public ExecutorService getExecutorService() {
+        return executorService;
+    }
+
+    /**
+     * Gets the executor service to submit daemon tasks.
+     *  
+     * @return the ExecutorService to submit normal daemon tasks.
+     */
+    public ExecutorService getExecutorServiceDeamons() {
+        return executorServiceDeamons;
+    }
+
+    /**
+     * Submits a Runnable task for normal execution and returns a Future representing that task. The Future's
+     * {@code get} method will return {@code null} upon <em>successful</em> completion.
+     *
+     * @param task the task to submit
+     * @return a Future representing pending completion of the task
+     * @throws RejectedExecutionException if the task cannot be
+     *         scheduled for execution
+     * @throws NullPointerException if the task is null
+     */
+    public Future<?> submit(Runnable task) {
+        return executorService.submit(task);
+    }
+
+    /**
+     * Submits a Runnable task for daemon execution and returns a Future representing that task. The Future's
+     * {@code get} method will return {@code null} upon <em>successful</em> completion.
+     *
+     * @param task
+     *            the task to submit
+     * @return a Future representing pending completion of the task
+     * @throws RejectedExecutionException
+     *             if the task cannot be scheduled for execution
+     * @throws NullPointerException
+     *             if the task is null
+     */
+    public Future<?> submitDaemon(Runnable task) {
+        return executorServiceDeamons.submit(task);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 4c78e7f..dbe1bc4 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
@@ -23,6 +23,7 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.status.StatusLogger;
 
@@ -116,6 +117,11 @@ public abstract class AbstractManager {
         return count;
     }
 
+    public LoggerContext getLoggerContext() {
+        // TODO Can and should a manager tracks it's logger context?
+        return LoggerContext.getContext(false);
+    }
+
     /**
      * Called to signify that this Manager is no longer required by an Appender.
      */

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 d535e02..21224e3 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
@@ -26,7 +26,6 @@ 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 {
 
@@ -38,7 +37,7 @@ public class KafkaManager extends AbstractManager {
     static KafkaProducerFactory producerFactory = new DefaultKafkaProducerFactory();
 
     private final Properties config = new Properties();
-    private Producer<byte[], byte[]> producer = null;
+    private Producer<byte[], byte[]> producer;
     private final int timeoutMillis;
 
     private final String topic;
@@ -59,17 +58,17 @@ public class KafkaManager extends AbstractManager {
     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() {
+            final Runnable task = new Runnable() {
                 @Override
                 public void run() {
-                    producer.close();
+                    if (producer != null) {
+                        producer.close();
+                    }
                 }
-            }, "KafkaManager-CloseThread");
-            closeThread.setDaemon(true); // avoid blocking JVM shutdown
-            closeThread.start();
+            };
             try {
-                closeThread.join(timeoutMillis);
-            } catch (final InterruptedException ignore) {
+                getLoggerContext().submitDaemon(task).get(timeoutMillis, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 // ignore
             }
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
index 3c6739f..3fcf864 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
@@ -17,24 +17,23 @@
 package org.apache.logging.log4j.core.appender.rolling;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Serializable;
 import java.nio.ByteBuffer;
+import java.util.concurrent.Future;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 
 import org.apache.logging.log4j.core.Layout;
 import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.FileManager;
 import org.apache.logging.log4j.core.appender.ManagerFactory;
 import org.apache.logging.log4j.core.appender.rolling.action.AbstractAction;
 import org.apache.logging.log4j.core.appender.rolling.action.Action;
-import org.apache.logging.log4j.core.util.Clock;
 import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.core.util.Log4jThread;
 
 /**
  * The Rolling File Manager.
@@ -236,7 +235,7 @@ public class RollingFileManager extends FileManager {
         }
 
         boolean success = false;
-        Thread thread = null;
+        Future<?> future = null;
 
         try {
             final RolloverDescription descriptor = strategy.rollover(this);
@@ -254,14 +253,13 @@ public class RollingFileManager extends FileManager {
 
                 if (success && descriptor.getAsynchronous() != null) {
                     LOGGER.debug("RollingFileManager executing async {}", descriptor.getAsynchronous());
-                    thread = new Log4jThread(new AsyncAction(descriptor.getAsynchronous(), this));
-                    thread.start();
+                    future = LoggerContext.getContext(false).submit(new AsyncAction(descriptor.getAsynchronous(), this));
                 }
                 return true;
             }
             return false;
         } finally {
-            if (thread == null || !thread.isAlive()) {
+            if (future == null || future.isDone() || future.isCancelled()) {
                 semaphore.release();
             }
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 744ed24..4987082 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
@@ -39,17 +39,16 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
 
     private int scheduledItems = 0;
 
-
     @Override
     public void start() {
         super.start();
         if (scheduledItems > 0) {
-            LOGGER.debug("Starting {} Log4j2Scheduled threads", scheduledItems);
+            LOGGER.debug("Starting {} Log4j2 Scheduled threads", scheduledItems);
             if (scheduledItems > 5) {
                 scheduledItems = 5;
             }
             executorService = new ScheduledThreadPoolExecutor(scheduledItems,
-                    Log4jThreadFactory.createDaemonThreadFactory("Log4j2Scheduled"));
+                    Log4jThreadFactory.createDaemonThreadFactory("Scheduled"));
         } else {
             LOGGER.debug("No scheduled items");
         }
@@ -58,7 +57,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
     @Override
     public void stop() {
         if (executorService != null) {
-            LOGGER.debug("Stopping Log4j2Scheduled threads.");
+            LOGGER.debug("Stopping Log4j2 Scheduled threads.");
             executorService.shutdown();
         }
         super.stop();
@@ -86,6 +85,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
 
     /**
      * Creates and executes a ScheduledFuture that becomes enabled after the given delay.
+     * @param <V> The result type returned by this Future
      * @param callable the function to execute.
      * @param delay the time from now to delay execution.
      * @param unit the time unit of the delay parameter.

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
index ceb6b57..cadb5e1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
@@ -16,12 +16,12 @@
  */
 package org.apache.logging.log4j.core.config;
 
-import org.apache.logging.log4j.core.util.FileWatcher;
-import org.apache.logging.log4j.core.util.Log4jThread;
-
 import java.io.File;
 import java.util.List;
 
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.util.FileWatcher;
+
 /**
  * Watcher for configuration files. Causes a reconfiguration when a file changes.
  */
@@ -43,9 +43,7 @@ public class ConfiguratonFileWatcher implements FileWatcher {
     @Override
     public void fileModified(final File file) {
         for (final ConfigurationListener listener : listeners) {
-            final Thread thread = new Log4jThread(new ReconfigurationWorker(listener, reconfigurable));
-            thread.setDaemon(true);
-            thread.start();
+            LoggerContext.getContext(false).submitDaemon(new ReconfigurationWorker(listener, reconfigurable));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
index e8286c1..3da469d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
@@ -20,6 +20,7 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
@@ -328,8 +329,15 @@ public final class Configurator {
     }
 
     /**
-     * Shuts down the given logging context.
-     * @param ctx the logging context to shut down, may be null.
+     * Shuts down the given logger context. This request does not wait for Log4j tasks to complete.
+     * <p>
+     * Log4j starts threads to perform certain actions like file rollovers; calling this method will not wait until the
+     * rollover thread is done. When this method returns, these tasks' status are undefined, the tasks may be done or
+     * not.
+     * </p>
+     * 
+     * @param ctx
+     *            the logger context to shut down, may be null.
      */
     public static void shutdown(final LoggerContext ctx) {
         if (ctx != null) {
@@ -337,6 +345,30 @@ public final class Configurator {
         }
     }
 
+    /**
+     * Blocks until all Log4j tasks have completed execution after a shutdown request, or the timeout occurs, or the
+     * current thread is interrupted, whichever happens first.
+     * <p>
+     * Log4j can start threads to perform certain actions like file rollovers, calling this method with a timeout will
+     * block until the rollover thread is done.
+     * </p>
+     * 
+     * @param ctx
+     *            the logger context to shut down, may be null.
+     * @param timeout
+     *            the maximum time to wait
+     * @param timeUnit
+     *            the time unit of the timeout argument
+     * @return {@code true} if the logger context terminated and {@code false} if the timeout elapsed before
+     *         termination.
+     */
+    public static boolean shutdown(final LoggerContext ctx, final long timeout, final TimeUnit timeUnit) {
+        if (ctx != null) {
+            return ctx.stop(timeout, timeUnit);
+        }
+        return true;
+    }
+
     private Configurator() {
         // empty
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 10f343a..2c51758 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
@@ -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 = "jmx.notif";
     private static final StatusLogger LOGGER = StatusLogger.getLogger();
     static final Executor executor = isJmxDisabled() ? null : createExecutor();
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 752fc13..74a3834 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
@@ -107,6 +107,13 @@ public class JmsServer extends LogEventListener implements MessageListener, Life
         jmsManager.release();
     }
 
+    @Override
+    public boolean stop(long timeout, TimeUnit timeUnit) {
+        stop();
+        return true;
+    }
+
+    @Override
     public boolean isStarted() {
         return state.get() == State.STARTED;
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
index 45ae6f5..1aab6c7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.logging.log4j.Logger;
@@ -163,6 +164,12 @@ public class DefaultShutdownCallbackRegistry implements ShutdownCallbackRegistry
         }
     }
 
+    @Override
+    public boolean stop(long timeout, TimeUnit timeUnit) {
+        stop();
+        return true;
+    }
+
     private void removeShutdownHook() {
         final Thread shutdownThread = shutdownHookRef.get();
         if (shutdownThread != null) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 333ca0a..2f974e4 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
@@ -40,6 +40,17 @@ public class Log4jThreadFactory implements ThreadFactory {
         return new Log4jThreadFactory(threadNamePrefix, true, Thread.NORM_PRIORITY);
     }
 
+    /**
+     * Creates a new thread factory.
+     * 
+     * @param threadNamePrefix
+     *            The thread name prefix.
+     * @return a new daemon thread factory.
+     */
+    public static Log4jThreadFactory createThreadFactory(final String threadNamePrefix) {
+        return new Log4jThreadFactory(threadNamePrefix, false, 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;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
index 2c6fdd3..c24fa50 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
@@ -57,7 +57,7 @@ public class RandomRollingAppenderOnStartupTest {
     public LoggerContextRule loggerContextRule;
 
     public RandomRollingAppenderOnStartupTest(final String configFile) {
-        this.loggerContextRule = new LoggerContextRule(configFile);
+        this.loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(configFile);
     }
 
     @Before

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
index 6de7d7d..d04de19 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
@@ -49,7 +49,7 @@ public class RollingAppenderCronTest {
     private static final String DIR = "target/rolling-cron";
     private static final String FILE = "target/rolling-cron/rollingtest.log";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
index 2e48ef8..3b30bd8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
@@ -37,7 +37,7 @@ public class RollingAppenderCustomDeleteActionTest {
     private static final String CONFIG = "log4j-rolling-with-custom-delete.xml";
     private static final String DIR = "target/rolling-with-delete/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
index e2e59e6..23dcffa 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
@@ -47,7 +47,7 @@ public class RollingAppenderDeleteAccumulatedCount1Test {
     private static final String CONFIG = "log4j-rolling-with-custom-delete-accum-count1.xml";
     private static final String DIR = "target/rolling-with-delete-accum-count1/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
index e03c53a..f636275 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
@@ -47,7 +47,7 @@ public class RollingAppenderDeleteAccumulatedCount2Test {
     private static final String CONFIG = "log4j-rolling-with-custom-delete-accum-count2.xml";
     private static final String DIR = "target/rolling-with-delete-accum-count2/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
index f6bfee3..f580b79 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
@@ -37,7 +37,7 @@ public class RollingAppenderDeleteAccumulatedSizeTest {
     private static final String CONFIG = "log4j-rolling-with-custom-delete-accum-size.xml";
     private static final String DIR = "target/rolling-with-delete-accum-size/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
index bef09c4..740f9ec 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
@@ -44,7 +44,7 @@ public class RollingAppenderDeleteMaxDepthTest {
     private static final String CONFIG = "log4j-rolling-with-custom-delete-maxdepth.xml";
     private static final String DIR = "target/rolling-with-delete-depth/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
index 081a52e..7d335f0 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
@@ -46,7 +46,7 @@ public class RollingAppenderDeleteNestedTest {
     private static final String CONFIG = "log4j-rolling-with-custom-delete-nested.xml";
     private static final String DIR = "target/rolling-with-delete-nested/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
index a7dcb48..38dca95 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
@@ -36,7 +36,7 @@ public class RollingAppenderDeleteScriptFri13thTest {
     private static final String CONFIG = "log4j-rolling-with-custom-delete-script-fri13th.xml";
     private static final String DIR = "target/rolling-with-delete-script-fri13th/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
index f1c3888..91da1a7 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
@@ -34,7 +34,7 @@ public class RollingAppenderDeleteScriptTest {
     private static final String CONFIG = "log4j-rolling-with-custom-delete-script.xml";
     private static final String DIR = "target/rolling-with-delete-script/test";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
index d7834f5..0d34be6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
@@ -58,7 +58,7 @@ public class RollingAppenderNoUnconditionalDeleteTest {
 
     public RollingAppenderNoUnconditionalDeleteTest(final String configFile, final String dir) {
         this.directory = new File(dir);
-        this.loggerContextRule = new LoggerContextRule(configFile);
+        this.loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(configFile);
         deleteDir();
         deleteDirParent();
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java
index bc74585..aed2d19 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java
@@ -57,7 +57,7 @@ public class RollingAppenderOnStartupTest {
     public LoggerContextRule loggerContextRule;
 
     public RollingAppenderOnStartupTest(final String configFile) {
-        this.loggerContextRule = new LoggerContextRule(configFile);
+        this.loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(configFile);
     }
 
     @Before

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
index d354b41..6e73ab3 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
@@ -94,7 +94,7 @@ public class RollingAppenderSizeTest {
     public RollingAppenderSizeTest(final String configFile, final String fileExtension, final boolean createOnDemand) {
         this.fileExtension = fileExtension;
         this.createOnDemand = createOnDemand;
-        this.loggerContextRule = new LoggerContextRule(configFile);
+        this.loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(configFile);
         this.chain = loggerContextRule.withCleanFoldersRule(DIR);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
index bec238e..ad0ea64 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
@@ -38,9 +38,11 @@ import org.junit.rules.RuleChain;
  */
 public class RollingAppenderTimeAndSizeTest {
 
+    private static final String CONFIG = "log4j-rolling3.xml";
+
     private static final String DIR = "target/rolling3/test";
 
-    public static LoggerContextRule loggerContextRule = new LoggerContextRule("log4j-rolling3.xml");
+    public static LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
index aa99595..089908d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
@@ -40,7 +40,7 @@ public class RollingAppenderTimeTest {
     private static final String CONFIG = "log4j-rolling2.xml";
     private static final String DIR = "target/rolling2";
 
-    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
+    private final LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
index af668d8..6734d6b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
@@ -39,10 +39,11 @@ import org.junit.rules.RuleChain;
  */
 public class RollingRandomAccessFileManagerHeaderFooterTest {
 
+    private static final String CONFIG = "RollingRandomAccessFileAppenderHeaderFooterTest.xml";
     private static final String DIR = "target/RollingRandomAccessFileAppenderHeaderFooterTest/";
     private static final String LOGFILE = "target/RollingRandomAccessFileAppenderHeaderFooterTest.log";
 
-    public LoggerContextRule loggerContextRule = new LoggerContextRule("RollingRandomAccessFileAppenderHeaderFooterTest.xml");
+    public LoggerContextRule loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f92f7cc/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 697e119..c3aaef9 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
@@ -18,6 +18,8 @@ package org.apache.logging.log4j.junit;
 
 import static org.junit.Assert.assertNotNull;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Logger;
@@ -41,12 +43,18 @@ import org.junit.runners.model.Statement;
  */
 public class LoggerContextRule implements TestRule {
 
+    public static LoggerContextRule createShutdownTimeoutLoggerContextRule(String config) {
+        return new LoggerContextRule(config, 10, TimeUnit.SECONDS);
+    }
+    
     private static final String SYS_PROP_KEY_CLASS_NAME = "org.apache.logging.log4j.junit.LoggerContextRule#ClassName";
     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;
+    private long shutdownTimeout;
+    private TimeUnit shutdownTimeUnit;
 
     /**
      * Constructs a new LoggerContextRule for a given configuration file.
@@ -65,11 +73,21 @@ public class LoggerContextRule implements TestRule {
      *            path to configuration file
      * @param contextSelectorClass
      *            custom ContextSelector class to use instead of default
-     * @since 2.5
      */
     public LoggerContextRule(final String configLocation, final Class<? extends ContextSelector> contextSelectorClass) {
+        this(configLocation, contextSelectorClass, 0, null);
+    }
+
+    public LoggerContextRule(final String configLocation, final Class<? extends ContextSelector> contextSelectorClass,
+            final long shutdownTimeout, final TimeUnit shutdownTimeUnit) {
         this.configLocation = configLocation;
         this.contextSelectorClass = contextSelectorClass;
+        this.shutdownTimeout = shutdownTimeout;
+        this.shutdownTimeUnit = shutdownTimeUnit;
+    }
+
+    public LoggerContextRule(String config, int shutdownTimeout, TimeUnit shutdownTimeUnit) {
+        this(config, null, shutdownTimeout, shutdownTimeUnit);
     }
 
     @Override
@@ -94,7 +112,10 @@ public class LoggerContextRule implements TestRule {
                 try {
                     base.evaluate();
                 } finally {
-                    Configurator.shutdown(context);
+                    if (!Configurator.shutdown(context, shutdownTimeout, shutdownTimeUnit)) {
+                        StatusLogger.getLogger().error("Logger context {} did not shutdown completely after {} {}.",
+                                context.getName(), shutdownTimeout, shutdownTimeUnit);
+                    }
                     context = null;
                     contextSelectorClass = null;
                     StatusLogger.getLogger().reset();


[39/42] logging-log4j2 git commit: [LOG4J2-1511] DynamicThresholdFilter filters incorrectly when params are passed as individual arguments instead of varargs.

Posted by rp...@apache.org.
[LOG4J2-1511] DynamicThresholdFilter filters incorrectly when params are
passed as individual arguments instead of varargs.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 0c9c9f384475af3402833e9a2a27e97248b84b38
Parents: 13feb49
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 22:14:47 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 22:14:47 2016 -0700

----------------------------------------------------------------------
 .../core/filter/DynamicThresholdFilter.java     | 79 ++++++++++++++++++++
 .../core/filter/DynamicThresholdFilterTest.java | 17 +++++
 src/changes/changes.xml                         |  3 +
 3 files changed, 99 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c9c9f38/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
index 2a2d54c..24cfada 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
@@ -149,6 +149,85 @@ public final class DynamicThresholdFilter extends AbstractFilter {
         return filter(level, ThreadContext.getContext());
     }
 
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2, final Object p3) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2, final Object p3,
+            final Object p4) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2, final Object p3,
+            final Object p4, final Object p5) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2, final Object p3,
+            final Object p4, final Object p5, final Object p6) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2, final Object p3,
+            final Object p4, final Object p5, final Object p6,
+            final Object p7) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2, final Object p3,
+            final Object p4, final Object p5, final Object p6,
+            final Object p7, final Object p8) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+
+    @Override
+    public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+            final Object p0, final Object p1, final Object p2, final Object p3,
+            final Object p4, final Object p5, final Object p6,
+            final Object p7, final Object p8, final Object p9) {
+        return filter(level, ThreadContext.getContext());
+
+    }
+    
     public String getKey() {
         return this.key;
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c9c9f38/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
index 21f1ca0..1cf6b60 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
@@ -74,9 +74,26 @@ public class DynamicThresholdFilterTest {
         assertSame(Filter.Result.DENY, filter.filter(event));
         event = Log4jLogEvent.newBuilder().setLevel(Level.ERROR).setMessage(new SimpleMessage("Test")).build();
         assertSame(Filter.Result.NEUTRAL, filter.filter(event));
+        ThreadContext.clearMap();
     }
 
     @Test
+    public void testFilterWorksWhenParamsArePassedAsArguments() {
+        ThreadContext.put("userid", "testuser");
+        ThreadContext.put("organization", "apache");
+        final KeyValuePair[] pairs = new KeyValuePair[] {
+                new KeyValuePair("testuser", "DEBUG"),
+                new KeyValuePair("JohnDoe", "warn") };
+        final DynamicThresholdFilter filter = DynamicThresholdFilter.createFilter("userid", pairs, Level.ERROR, Filter.Result.ACCEPT, Filter.Result.NEUTRAL);
+        filter.start();
+        assertTrue(filter.isStarted());
+        Object [] replacements = {"one", "two", "three"};
+        assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, null, "some test message", replacements)); 
+        assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, null, "some test message", "one", "two", "three")); 
+        ThreadContext.clearMap();
+    }
+    
+    @Test
     public void testConfig() {
         try (final LoggerContext ctx = Configurator.initialize("Test1",
                 "target/test-classes/log4j2-dynamicfilter.xml")) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c9c9f38/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2a1f57a..818f570 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
   </properties>
   <body>
     <release version="2.7" date="2016-MM-DD" description="GA Release 2.7">
+      <action issue="LOG4J2-1511" dev="ggregory" type="fix" due-to="Srikanth Surukuntu">
+        DynamicThresholdFilter filters incorrectly when params are passed as individual arguments instead of varargs.
+      </action>
       <action issue="LOG4J2-1548" dev="ggregory" type="fix">
         [CronTriggeringPolicy] ConfigurationScheduler schedules the task infinitely after first fire.
       </action>


[28/42] logging-log4j2 git commit: Javadoc.

Posted by rp...@apache.org.
Javadoc.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 498eef5569a93606cb4784f20e51c4b93cf40bd3
Parents: 213a247
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 08:55:33 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 08:55:33 2016 -0700

----------------------------------------------------------------------
 .../logging/log4j/core/config/xml/XmlConfigurationFactory.java      | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/498eef55/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
index 9de84aa..a37718f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
@@ -37,6 +37,7 @@ public class XmlConfigurationFactory extends ConfigurationFactory {
 
     /**
      * Returns the Configuration.
+     * @param loggerContext The logger context.
      * @param source The InputSource.
      * @return The Configuration.
      */


[35/42] logging-log4j2 git commit: Added org.apache.logging.log4j.core.layout.CsvParameterLayoutTest.testLogJsonArgument() for [LOG4J2-1502] CsvParameterLayout is inserting NUL character if data starts with {, (, [ or "

Posted by rp...@apache.org.
Added
org.apache.logging.log4j.core.layout.CsvParameterLayoutTest.testLogJsonArgument()
for [LOG4J2-1502] CsvParameterLayout is inserting NUL character if data
starts with {, (, [ or "

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: ae218df64450d6e3d8744c07d173ed714473de19
Parents: d8d2ac0
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 18:01:41 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 18:01:41 2016 -0700

----------------------------------------------------------------------
 .../core/layout/CsvParameterLayoutTest.java     | 59 ++++++++++++++------
 1 file changed, 43 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ae218df6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
index 58ce1bd..f4eddd1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.csv.CSVFormat;
 import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.junit.LoggerContextRule;
@@ -49,19 +50,15 @@ import org.junit.runners.Parameterized;
 public class CsvParameterLayoutTest {
     @Parameterized.Parameters(name = "{0}")
     public static Collection<Object[]> data() {
-        return Arrays.asList(
-                new Object[][]{
-                        { new LoggerContextRule("csvParamsSync.xml"), },
-                        { new LoggerContextRule("csvParamsMixedAsync.xml"), },
-                }
-        );
+        return Arrays.asList(new Object[][] { { new LoggerContextRule("csvParamsSync.xml"), },
+                { new LoggerContextRule("csvParamsMixedAsync.xml"), }, });
     }
 
     @Rule
     public final LoggerContextRule init;
 
     @Rule
-    public final ThreadContextRule threadContextRule = new ThreadContextRule(); 
+    public final ThreadContextRule threadContextRule = new ThreadContextRule();
 
     public CsvParameterLayoutTest(final LoggerContextRule contextRule) {
         this.init = contextRule;
@@ -86,11 +83,9 @@ public class CsvParameterLayoutTest {
         assertEquals("text/csv; charset=UTF-8", layout.getContentType());
     }
 
-    static void testLayoutNormalApi(final Logger root, final AbstractCsvLayout layout, final boolean messageApi) throws Exception {
-        final Map<String, Appender> appenders = root.getAppenders();
-        for (final Appender appender : appenders.values()) {
-            root.removeAppender(appender);
-        }
+    static void testLayoutNormalApi(final Logger root, final AbstractCsvLayout layout, final boolean messageApi)
+            throws Exception {
+        removeAppenders(root);
         // set up appender
         final ListAppender appender = new ListAppender("List", null, layout, true, false);
         appender.start();
@@ -107,10 +102,12 @@ public class CsvParameterLayoutTest {
         } else {
             logDebugNormalApi(root);
         }
-
-        // wait until background thread finished processing
-        appender.countDownLatch.await(10, TimeUnit.SECONDS);
-        assertEquals("Background thread did not finish processing: msg count", 4, appender.getMessages().size());
+        final int msgCount = 4;
+        if (appender.getMessages().size() < msgCount) {
+            // wait until background thread finished processing
+            appender.countDownLatch.await(10, TimeUnit.SECONDS);
+        }
+        assertEquals("Background thread did not finish processing: msg count", msgCount, appender.getMessages().size());
 
         // don't stop appender until background thread is done
         appender.stop();
@@ -123,6 +120,13 @@ public class CsvParameterLayoutTest {
         Assert.assertEquals("7" + d + "8" + d + "9" + d + "10", list.get(3));
     }
 
+    private static void removeAppenders(final Logger root) {
+        final Map<String, Appender> appenders = root.getAppenders();
+        for (final Appender appender : appenders.values()) {
+            root.removeAppender(appender);
+        }
+    }
+
     private static void logDebugNormalApi(final Logger root) {
         root.debug("with placeholders: {}{}{}", 1, 2, 3);
         root.debug("without placeholders", 2, 3);
@@ -154,4 +158,27 @@ public class CsvParameterLayoutTest {
         final Logger root = this.init.getRootLogger();
         testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true);
     }
+
+    @Test
+    public void testLogJsonArgument() throws InterruptedException {
+        ListAppender appender = (ListAppender) init.getAppender("List");
+        appender.countDownLatch = new CountDownLatch(4);
+        appender.clear();
+        Logger logger = (Logger) LogManager.getRootLogger();
+        final String json = "{\"id\":10,\"name\":\"Alice\"}";
+        logger.error("log:{}", json);
+        // wait until background thread finished processing
+        final int msgCount = 1;
+        if (appender.getMessages().size() < msgCount) {
+            appender.countDownLatch.await(5, TimeUnit.SECONDS);
+        }
+        assertEquals("Background thread did not finish processing: msg count", msgCount, appender.getMessages().size());
+
+        // don't stop appender until background thread is done
+        appender.stop();
+        final List<String> list = appender.getMessages();
+        final String eventStr = list.get(0).toString();
+        Assert.assertTrue(eventStr, eventStr.contains(json));
+    }
+
 }


[20/42] logging-log4j2 git commit: Merge remote-tracking branch 'origin/master' into LOG4J2-1539

Posted by rp...@apache.org.
Merge remote-tracking branch 'origin/master' into LOG4J2-1539

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: a4ef9a1de092e8f4748716e62dff0d6972c1bcb1
Parents: d18e9c9 29e7bfd
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 14:43:20 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 14:43:20 2016 -0700

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      |    9 +-
 .../log4j/config/Log4j1ConfigurationParser.java |  210 ++--
 .../apache/log4j/BasicConfigurationFactory.java |   13 +-
 .../config/Log4j1ConfigurationFactoryTest.java  |   29 +-
 ...g4j-console-EnhancedPatternLayout.properties |    1 -
 .../log4j-console-HtmlLayout.properties         |    1 -
 .../log4j-console-PatternLayout.properties      |    1 -
 .../log4j-console-SimpleLayout.properties       |    1 -
 .../log4j-console-TTCCLayout.properties         |    1 -
 .../log4j-console-XmlLayout.properties          |    1 -
 .../log4j-file-SimpleLayout.properties          |   17 +
 .../logging/log4j/core/LoggerContext.java       |    2 +-
 .../core/config/AbstractConfiguration.java      |   15 +-
 .../log4j/core/config/Configuration.java        |    8 +
 .../log4j/core/config/ConfigurationFactory.java | 1113 +++++++++---------
 .../core/config/ConfigurationScheduler.java     |    2 +-
 .../log4j/core/config/DefaultConfiguration.java |    2 +-
 .../log4j/core/config/NullConfiguration.java    |    2 +-
 .../builder/api/ConfigurationBuilder.java       |    8 +
 .../config/builder/impl/BuiltConfiguration.java |    5 +-
 .../impl/DefaultConfigurationBuilder.java       |   29 +-
 .../composite/CompositeConfiguration.java       |    4 +-
 .../core/config/json/JsonConfiguration.java     |   14 +-
 .../config/json/JsonConfigurationFactory.java   |    5 +-
 .../core/config/plugins/util/ResolverUtil.java  |   11 +-
 .../properties/PropertiesConfiguration.java     |    8 +-
 .../PropertiesConfigurationBuilder.java         |   16 +-
 .../PropertiesConfigurationFactory.java         |   10 +-
 .../log4j/core/config/xml/XmlConfiguration.java |    7 +-
 .../config/xml/XmlConfigurationFactory.java     |    5 +-
 .../core/config/yaml/YamlConfiguration.java     |    7 +-
 .../config/yaml/YamlConfigurationFactory.java   |    5 +-
 .../log4j/core/impl/Log4jContextFactory.java    |    6 +-
 .../log4j/core/jmx/LoggerContextAdmin.java      |    4 +-
 .../apache/logging/log4j/core/jmx/Server.java   |    4 +
 .../core/net/server/AbstractSocketServer.java   |    7 +-
 .../log4j/core/BasicConfigurationFactory.java   |    6 +-
 .../RollingAppenderCronOnceADayTest.java        |  128 ++
 .../log4j/core/config/ConfigurationTest.java    |    6 +
 .../builder/CustomConfigurationFactory.java     |   11 +-
 .../plugins/util/PluginManagerPackagesTest.java |    2 +-
 .../util/ResolverUtilCustomProtocolTest.java    |  208 ++++
 .../config/plugins/util/ResolverUtilTest.java   |  146 ++-
 .../junit/URLStreamHandlerFactoryRule.java      |   96 ++
 .../resources/log4j-rolling-cron-once-a-day.xml |   47 +
 .../src/test/resources/log4j-rolling-cron.xml   |    2 +-
 .../src/test/resources/log4j-rolling-cron2.xml  |    2 +-
 .../configuration/CustomConfiguration.java      |   13 +-
 .../CustomConfigurationFactory.java             |   12 +-
 src/changes/changes.xml                         |    8 +-
 50 files changed, 1464 insertions(+), 806 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a4ef9a1d/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a4ef9a1d/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a4ef9a1d/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
----------------------------------------------------------------------


[31/42] logging-log4j2 git commit: [LOG4J2-1540] The Core AbstractManager should track its LoggerContext. Update Kafka support.

Posted by rp...@apache.org.
[LOG4J2-1540] The Core AbstractManager should track its LoggerContext.
Update Kafka support.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: b1acc7f7b15daa5c6ad686a9e26413a204bee3fc
Parents: 01f59e4
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 10:09:01 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 10:09:01 2016 -0700

----------------------------------------------------------------------
 .../logging/log4j/core/appender/mom/kafka/KafkaAppender.java  | 7 +++++--
 .../logging/log4j/core/appender/mom/kafka/KafkaManager.java   | 5 +++--
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b1acc7f7/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
index 8619f3d..81879e7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
@@ -26,10 +26,12 @@ import org.apache.logging.log4j.core.Layout;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.appender.AbstractAppender;
 import org.apache.logging.log4j.core.appender.AppenderLoggingException;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.Node;
 import org.apache.logging.log4j.core.config.Property;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
 import org.apache.logging.log4j.core.config.plugins.PluginElement;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
 import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
@@ -49,8 +51,9 @@ public final class KafkaAppender extends AbstractAppender {
             @Required(message = "No name provided for KafkaAppender") @PluginAttribute("name") final String name,
             @PluginAttribute(value = "ignoreExceptions", defaultBoolean = true) final boolean ignoreExceptions,
             @Required(message = "No topic provided for KafkaAppender") @PluginAttribute("topic") final String topic,
-            @PluginElement("Properties") final Property[] properties) {
-        final KafkaManager kafkaManager = new KafkaManager(name, topic, properties);
+            @PluginElement("Properties") final Property[] properties,
+            @PluginConfiguration final Configuration configuration) {
+        final KafkaManager kafkaManager = new KafkaManager(configuration.getLoggerContext(), name, topic, properties);
         return new KafkaAppender(name, layout, filter, ignoreExceptions, kafkaManager);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b1acc7f7/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 d138c93..35aafb7 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
@@ -24,6 +24,7 @@ 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.LoggerContext;
 import org.apache.logging.log4j.core.appender.AbstractManager;
 import org.apache.logging.log4j.core.config.Property;
 
@@ -42,8 +43,8 @@ public class KafkaManager extends AbstractManager {
 
     private final String topic;
 
-    public KafkaManager(final String name, final String topic, final Property[] properties) {
-        super(null, name);
+    public KafkaManager(LoggerContext loggerContext, final String name, final String topic, final Property[] properties) {
+        super(loggerContext, name);
         this.topic = topic;
         config.setProperty("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
         config.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");


[32/42] logging-log4j2 git commit: [LOG4J2-1539] Add Core API Configurator.shutdown(LoggerContext, long, TimeUnit). Update changes.xml.

Posted by rp...@apache.org.
[LOG4J2-1539] Add Core API Configurator.shutdown(LoggerContext, long,
TimeUnit). Update changes.xml.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 38f1497e36ae872c8aa68a5ce302f1f0f732725d
Parents: b1acc7f
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 12:02:33 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 12:02:33 2016 -0700

----------------------------------------------------------------------
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/38f1497e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b170dc6..05aa5f7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -93,6 +93,9 @@
       <action issue="LOG4J2-1313" dev="rpopma" type="fix" due-to="Philipp Knobel">
         Properties declared in configuration can now have their value either in the element body or in an attribute named "value".
       </action>
+      <action issue="LOG4J2-1539" dev="ggregory" type="add" due-to="Gary Gregory">
+        Add Core API Configurator.shutdown(LoggerContext, long, TimeUnit).
+      </action>
       <action issue="LOG4J2-1501" dev="ggregory" type="add" due-to="Gary Gregory">
         FileAppender should be able to create files on-demand.
       </action>


[04/42] logging-log4j2 git commit: Merge remote-tracking branch 'origin/master' into LOG4J2-1547-AbstractConfiguration-with-LoggerContext

Posted by rp...@apache.org.
Merge remote-tracking branch 'origin/master' into LOG4J2-1547-AbstractConfiguration-with-LoggerContext

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 56eba730fdc36beaab05f6e9077f752d138125f1
Parents: 85c5e81 30ea283
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Aug 23 21:12:00 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Aug 23 21:12:00 2016 -0700

----------------------------------------------------------------------
 .../core/config/AbstractConfiguration.java      | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/56eba730/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
----------------------------------------------------------------------


[11/42] logging-log4j2 git commit: [LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not supported. Create a JUnit Rule to manage the URLStreamHandlerFactory.

Posted by rp...@apache.org.
[LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not
supported. Create a JUnit Rule to manage the URLStreamHandlerFactory.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 4157ef83fa64899a1fcccc528456b03520261dde
Parents: 73323cd
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 13:15:45 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 13:15:45 2016 -0700

----------------------------------------------------------------------
 .../util/ResolverUtilCustomProtocolTest.java    | 41 +++------
 .../junit/URLStreamHandlerFactoryRule.java      | 96 ++++++++++++++++++++
 2 files changed, 107 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4157ef83/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
index 86bc000..532b9ef 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
@@ -17,14 +17,9 @@
 
 package org.apache.logging.log4j.core.config.plugins.util;
 
-import static org.junit.Assert.assertEquals;
 import static org.apache.logging.log4j.core.config.plugins.util.ResolverUtilTest.compileAndCreateClassLoader;
 import static org.apache.logging.log4j.core.config.plugins.util.ResolverUtilTest.compileJarAndCreateClassLoader;
-
-import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.PluginTest;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
@@ -38,12 +33,22 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Hashtable;
 
+import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.PluginTest;
+import org.apache.logging.log4j.junit.URLStreamHandlerFactoryRule;
+import org.junit.AfterClass;
+import org.junit.Rule;
+import org.junit.Test;
+
 /**
  * Tests the ResolverUtil class for custom protocol like bundleresource, vfs, vfszip.
  */
 public class ResolverUtilCustomProtocolTest {
 
+    @Rule
+    public URLStreamHandlerFactoryRule rule = new URLStreamHandlerFactoryRule(new NoopURLStreamHandlerFactory());
+
     static class NoopURLStreamHandlerFactory implements URLStreamHandlerFactory {
+        
         @Override
         public URLStreamHandler createURLStreamHandler(String protocol) {
             return new URLStreamHandler() {
@@ -107,30 +112,6 @@ public class ResolverUtilCustomProtocolTest {
         }
     }
 
-    @BeforeClass
-    public static void defineURLHandler() {
-        URL.setURLStreamHandlerFactory(new NoopURLStreamHandlerFactory());
-    }
-
-    @AfterClass
-    public static void removeURLHandler() throws Exception {
-        // Simulate this - Not the best way, but no other choice welcome ?
-        // URL.setURLStreamHandlerFactory(null);
-        Field handlersFields = URL.class.getDeclaredField("handlers");
-        if (!handlersFields.isAccessible()) {
-            handlersFields.setAccessible(true);
-        }
-        Field factoryFields = URL.class.getDeclaredField("factory");
-        if (!factoryFields.isAccessible()) {
-            factoryFields.setAccessible(true);
-        }
-
-        @SuppressWarnings("unchecked")
-        Hashtable<String, URLStreamHandler> handlers = (Hashtable<String, URLStreamHandler>) handlersFields.get(null);
-        handlers.clear();
-        factoryFields.set(null, null);
-    }
-
     @Test
     public void testExtractPathFromVfsEarJarWindowsUrl() throws Exception {
         final URL url = new URL(

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4157ef83/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java
new file mode 100644
index 0000000..ac08bb3
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java
@@ -0,0 +1,96 @@
+/*
+ * 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.junit;
+
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.util.Hashtable;
+
+import org.junit.Assert;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+/**
+ * Installs and restores the URL URLStreamHandlerFactory before and after tests.
+ * <p>
+ * Might need tweaking for different JREs.
+ * </p>
+ */
+public class URLStreamHandlerFactoryRule implements TestRule {
+
+    public URLStreamHandlerFactoryRule() {
+        this(null);
+    }
+
+    public URLStreamHandlerFactoryRule(URLStreamHandlerFactory newURLStreamHandlerFactory) {
+        this.newURLStreamHandlerFactory = newURLStreamHandlerFactory;
+    }
+
+    private final URLStreamHandlerFactory newURLStreamHandlerFactory;
+
+    void clearURLHandlers() throws Exception {
+        Field handlersFields = URL.class.getDeclaredField("handlers");
+        if (handlersFields != null) {
+            if (!handlersFields.isAccessible()) {
+                handlersFields.setAccessible(true);
+            }
+            @SuppressWarnings("unchecked")
+            Hashtable<String, URLStreamHandler> handlers = (Hashtable<String, URLStreamHandler>) handlersFields
+                    .get(null);
+            if (handlers != null) {
+                handlers.clear();
+            }
+        }
+    }
+
+    @Override
+    public Statement apply(final Statement base, final Description description) {
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                Field factoryField = null;
+                int matches = 0;
+                URLStreamHandlerFactory oldFactory = null;
+                for (Field field : URL.class.getDeclaredFields()) {
+                    if (URLStreamHandlerFactory.class.equals(field.getType())) {
+                        factoryField = field;
+                        matches++;
+                        factoryField.setAccessible(true);
+                        oldFactory = (URLStreamHandlerFactory) factoryField.get(null);
+                        break;
+                    }
+                }
+                Assert.assertNotNull("java.net URL does not declare a java.net.URLStreamHandlerFactory field",
+                        factoryField);
+                Assert.assertEquals("java.net.URL declares multiple java.net.URLStreamHandlerFactory fields.", 1,
+                        matches);
+                URL.setURLStreamHandlerFactory(newURLStreamHandlerFactory);
+                try {
+                    base.evaluate();
+                } finally {
+                    clearURLHandlers();
+                    factoryField.set(null, null);
+                    URL.setURLStreamHandlerFactory(oldFactory);
+                }
+            }
+        };
+    }
+}


[17/42] logging-log4j2 git commit: Better lvarnames.

Posted by rp...@apache.org.
Better lvarnames.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: acbecc0bd14474a63ef09abb4e301048f9b6518f
Parents: 1db38fc
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 13:58:11 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 13:58:11 2016 -0700

----------------------------------------------------------------------
 .../log4j/core/config/plugins/util/ResolverUtilTest.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/acbecc0b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index 92e6ee9..f5d13eb 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -168,10 +168,10 @@ public class ResolverUtilTest {
     static URLClassLoader compileJarAndCreateClassLoader(String suffix) throws IOException, Exception {
         File workDir = compile(suffix);
         File jarFile = new File(workDir, "customplugin" + suffix + ".jar");
-        URI jarURL = jarFile.toURI();
-        createJar(jarURL, workDir, new File(workDir,
+        URI jarURI = jarFile.toURI();
+        createJar(jarURI, workDir, new File(workDir,
               "customplugin" + suffix + "/FixedString" + suffix + "Layout.class"));
-        return URLClassLoader.newInstance(new URL[] {jarURL.toURL()});
+        return URLClassLoader.newInstance(new URL[] {jarURI.toURL()});
     }
 
     static URLClassLoader compileAndCreateClassLoader(String suffix) throws IOException {
@@ -197,10 +197,10 @@ public class ResolverUtilTest {
         return workDir;
     }
 
-    static void createJar(URI jarURL, File workDir, File f) throws Exception {
+    static void createJar(URI jarURI, File workDir, File f) throws Exception {
         Map<String, String> env = new HashMap<>(); 
         env.put("create", "true");
-        URI uri = URI.create("jar:file://" + jarURL.getPath());
+        URI uri = URI.create("jar:file://" + jarURI.getPath());
         try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) {   
             Path path = zipfs.getPath(workDir.toPath().relativize(f.toPath()).toString());
             if (path.getParent() != null) {


[10/42] logging-log4j2 git commit: [LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not supported. Update changes.xml.

Posted by rp...@apache.org.
[LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not
supported. Update changes.xml.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 73323cd968f2c63a1b75ae3b5d4122a495945e70
Parents: 2d5812b
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 13:07:16 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 13:07:16 2016 -0700

----------------------------------------------------------------------
 src/changes/changes.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/73323cd9/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index dbc3310..c6e62dd 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -33,7 +33,7 @@
       <action issue="LOG4J2-1490" dev="ggregory" type="fix" due-to="Krzysztof Taborski, Gary Gregory">
         Log4j2 is creating empty log files.
       </action>
-      <action issue="LOG4J2-1320" dev="ggregory" type="fix" due-to="Paresh Varke, Pierrick Hymbert">
+      <action issue="LOG4J2-1320" dev="ggregory" type="fix" due-to="Paresh Varke, Pierrick Hymbert, Gary Gregory">
         Custom plugins are not loaded, URL protocol vfs is not supported.
       </action>
       <action issue="LOG4J2-1541" dev="ggregory" type="fix" due-to="Gary Gregory">


[19/42] logging-log4j2 git commit: [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext and add Configuration.getLoggerContext(). Update changes.xml.

Posted by rp...@apache.org.
[LOG4J2-1547] The Core AbstractConfiguration should track its
LoggerContext and add Configuration.getLoggerContext(). Update
changes.xml.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 29e7bfd0f230aad47dc852bac0464de9bd6f2316
Parents: 322ccf0
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 14:42:00 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 14:42:00 2016 -0700

----------------------------------------------------------------------
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29e7bfd0/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c6e62dd..4c8303a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -126,6 +126,9 @@
       <action issue="LOG4J2-1520" dev="ggregory" type="add" due-to="Gary Gregory">
         Add JUnit Rule implementations to manage the thread context.
       </action>
+      <action issue="LOG4J2-1547" dev="ggregory" type="add" due-to="Gary Gregory">
+        The Core AbstractConfiguration should track its LoggerContext and add Configuration.getLoggerContext().
+      </action>
       <action issue="LOG4J2-1458" dev="ggregory" type="update" due-to="Gary Gregory">
         Update Jackson from 2.7.5 to 2.8.0.
       </action>


[36/42] logging-log4j2 git commit: Fix due-to's for myself.

Posted by rp...@apache.org.
Fix due-to's for myself.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 82032fc6a0c4882f74334bc872a6ed8e16d3c271
Parents: ae218df
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 20:23:11 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 20:23:11 2016 -0700

----------------------------------------------------------------------
 src/changes/changes.xml | 46 ++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/82032fc6/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0afb959..2a1f57a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,7 +24,7 @@
   </properties>
   <body>
     <release version="2.7" date="2016-MM-DD" description="GA Release 2.7">
-      <action issue="LOG4J2-1548" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-1548" dev="ggregory" type="fix">
         [CronTriggeringPolicy] ConfigurationScheduler schedules the task infinitely after first fire.
       </action>
       <action issue="LOG4J2-1506" dev="ggregory" type="fix" due-to="Johannes Schleger">
@@ -36,13 +36,13 @@
       <action issue="LOG4J2-1320" dev="ggregory" type="fix" due-to="Paresh Varke, Pierrick Hymbert, Gary Gregory">
         Custom plugins are not loaded, URL protocol vfs is not supported.
       </action>
-      <action issue="LOG4J2-1541" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-1541" dev="ggregory" type="fix">
         Fix file handle resource leak in XmlConfiguration.XmlConfiguration(ConfigurationSource).
       </action>
       <action issue="LOG4J2-1538" dev="ggregory" type="fix" due-to="Igor Karpov">
         Dynamic removal of filter may cause NPE.
       </action>
-      <action issue="LOG4J2-1532" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-1532" dev="ggregory" type="fix">
         Attributes are not merged properly in composite configurations.
       </action>
       <action issue="LOG4J2-1529" dev="mattsicker" type="fix" due-to="Sridevi Narra">
@@ -135,37 +135,37 @@
       <action issue="LOG4J2-1540" dev="ggregory" type="add" due-to="Gary Gregory">
         The Core AbstractManager should track its LoggerContext.
       </action>
-      <action issue="LOG4J2-1458" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1458" dev="ggregory" type="update">
         Update Jackson from 2.7.5 to 2.8.0.
       </action>
-      <action issue="LOG4J2-1494" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1494" dev="ggregory" type="update">
         Update Jackson from 2.8.0 to 2.8.1.
       </action>
-      <action issue="LOG4J2-1495" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1495" dev="ggregory" type="update">
         Update LMAX Disruptor from 3.3.4 to 3.3.5.
       </action>
-      <action issue="LOG4J2-1496" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1496" dev="ggregory" type="update">
         Update Kafka client from 0.9.1.0 to 0.10.0.0.
       </action>
-      <action issue="LOG4J2-1533" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1533" dev="ggregory" type="update">
         Update Kafka client from 0.10.0.0 to 0.10.0.1.
       </action>
-      <action issue="LOG4J2-1487" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1487" dev="ggregory" type="update">
         Update JMS test from ActiveMQ 5.13.3 to 5.13.4.
       </action>
-      <action issue="LOG4J2-1551" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1551" dev="ggregory" type="update">
         Update JMS test from ActiveMQ 5.13.4 to 5.14.0.
       </action>
-      <action issue="LOG4J2-1543" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1543" dev="ggregory" type="update">
         Remove deprecated Core API org.apache.logging.log4j.core.util.Constants.UTF_8.
       </action>
-      <action issue="LOG4J2-1544" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1544" dev="ggregory" type="update">
         Remove deprecated Core API org.apache.logging.log4j.core.util.Assert.requireNonNull(T, String).
       </action>
-      <action issue="LOG4J2-1545" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1545" dev="ggregory" type="update">
         Remove deprecated Web API org.apache.logging.log4j.web.WebLookup.getServletContext().
       </action>
-      <action issue="LOG4J2-1546" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-1546" dev="ggregory" type="update">
         Remove deprecated Core API org.apache.logging.log4j.core.config.LoggerConfig.createLogger(String, Level, String, String , AppenderRef[] refs, Property[], Configuration config, Filter).
       </action>
     </release>
@@ -246,13 +246,13 @@
       <action issue="LOG4J2-1032" dev="rgoers" type="fix">
         Change RenameAction to use java.nio to better report rename failures.
       </action>
-      <action issue="LOG4J2-1407" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-1407" dev="ggregory" type="fix">
         Misleading WARN log events from Log4j about message factories and unexpected formatting.
       </action>
-      <action issue="LOG4J2-1408" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-1408" dev="ggregory" type="fix">
         The module log4j-liquibase is missing from BOM POM.
       </action>
-      <action issue="LOG4J2-1180" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-1180" dev="ggregory" type="fix">
         Logger cache does not account for message factory.
       </action>
       <action issue="LOG4J2-1402" dev="rgoers" type="fix">
@@ -841,7 +841,7 @@
       <action issue="LOG4J2-1114" dev="ggregory" type="update">
         Add thread name to status logger layout.
       </action>
-      <action issue="LOG4J2-1123" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-1123" dev="ggregory" type="fix">
         Core Configurator.initialize(String, ClassLoader, String) fails to work when config location is a file path.
       </action>
       <action issue="LOG4J2-1117" dev="ggregory" type="fix" due-to="Marcus Thiesen">
@@ -1074,7 +1074,7 @@
       <action issue="LOG4J2-981" dev="ggregory" type="fix" due-to="Mikhail Mazurskiy">
         Incorrect unlock in ProviderUtil.
       </action>
-      <action issue="LOG4J2-966" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-966" dev="ggregory" type="fix">
         KeyStoreConfiguration.createKeyStoreConfiguration() ignores keyManagerFactoryAlgorithm.
       </action>
       <action issue="LOG4J2-976" dev="ggregory" type="fix" due-to="Matt Quinn">
@@ -1095,19 +1095,19 @@
       <action issue="LOG4J2-971" dev="ggregory" type="fix" due-to="Paul D Johe">
         Another bad priority in Syslog messages.
       </action>
-      <action issue="LOG4J2-972" dev="ggregory" type="fix" due-to="Gary Gregory">
+      <action issue="LOG4J2-972" dev="ggregory" type="fix">
         org.apache.logging.log4j.core.net.ssl.TlsSyslogInputStreamReader does not need to create temp Integer objects.
       </action>
       <action issue="LOG4J2-974" dev="ggregory" type="fix" due-to="Daniel Gal�n y Martins">
         Typo in EventLogger documentation.
       </action>
-      <action issue="LOG4J2-988" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-988" dev="ggregory" type="update">
         Update LMAX Disruptor from 3.3.0 to 3.3.2.
       </action>
-      <action issue="LOG4J2-987" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-987" dev="ggregory" type="update">
         Migrate tests from Logback 1.1.2 to 1.1.3.
       </action>
-      <action issue="LOG4J2-988" dev="ggregory" type="update" due-to="Gary Gregory">
+      <action issue="LOG4J2-988" dev="ggregory" type="update">
         Update tests to use ActiveMQ from 5.10 to 5.11.1.
       </action>
       <action issue="LOG4J2-1004" dev="ggregory" type="update">


[23/42] logging-log4j2 git commit: [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext and add Configuration.getLoggerContext(). Tie up loose end in CompositeConfiguration.

Posted by rp...@apache.org.
[LOG4J2-1547] The Core AbstractConfiguration should track its
LoggerContext and add Configuration.getLoggerContext(). Tie up loose end
in CompositeConfiguration.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: da5d6f33129146ac403df7bcab4c6e0c98095c46
Parents: 095a4bd
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 22:24:12 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 22:24:12 2016 -0700

----------------------------------------------------------------------
 .../log4j/core/config/composite/CompositeConfiguration.java        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/da5d6f33/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
index a1f1557..fa941d7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
@@ -62,7 +62,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
      * @param configurations The List of Configurations to merge.
      */
     public CompositeConfiguration(final List<? extends AbstractConfiguration> configurations) {
-        super(null, ConfigurationSource.NULL_SOURCE);
+        super(configurations.get(0).getLoggerContext(), ConfigurationSource.NULL_SOURCE);
         rootNode = configurations.get(0).getRootNode();
         this.configurations = configurations;
         final String mergeStrategyClassName = PropertiesUtil.getProperties().getStringProperty(MERGE_STRATEGY_PROPERTY,


[13/42] logging-log4j2 git commit: Merge remote-tracking branch 'origin/master' into LOG4J2-1547-AbstractConfiguration-with-LoggerContext

Posted by rp...@apache.org.
Merge remote-tracking branch 'origin/master' into LOG4J2-1547-AbstractConfiguration-with-LoggerContext

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: e15d0c7126884f67dd81067e4bc939631a38ba26
Parents: 56eba73 e033027
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 13:20:29 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 13:20:29 2016 -0700

----------------------------------------------------------------------
 .../core/config/ConfigurationScheduler.java     |   2 +-
 .../core/config/plugins/util/ResolverUtil.java  |  11 +-
 .../apache/logging/log4j/core/jmx/Server.java   |   4 +
 .../RollingAppenderCronOnceADayTest.java        | 128 ++++++++++++
 .../plugins/util/PluginManagerPackagesTest.java |   2 +-
 .../util/ResolverUtilCustomProtocolTest.java    | 208 +++++++++++++++++++
 .../config/plugins/util/ResolverUtilTest.java   | 146 +++++++------
 .../junit/URLStreamHandlerFactoryRule.java      |  96 +++++++++
 .../resources/log4j-rolling-cron-once-a-day.xml |  47 +++++
 .../src/test/resources/log4j-rolling-cron.xml   |   2 +-
 .../src/test/resources/log4j-rolling-cron2.xml  |   2 +-
 src/changes/changes.xml                         |   5 +-
 12 files changed, 585 insertions(+), 68 deletions(-)
----------------------------------------------------------------------



[06/42] logging-log4j2 git commit: [LOG4J2-1506] Unregister JMX ignores log4j2.disable.jmx property.

Posted by rp...@apache.org.
[LOG4J2-1506] Unregister JMX ignores log4j2.disable.jmx property.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 8b40c1f0e3b53277c399511923f9d7b2aa110fea
Parents: 30ea283
Author: Gary Gregory <gg...@apache.org>
Authored: Wed Aug 24 08:05:52 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Wed Aug 24 08:05:52 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/logging/log4j/core/jmx/Server.java  | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8b40c1f0/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 39cafeb..438f501 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
@@ -238,6 +238,10 @@ public final class Server {
      * @param loggerContextName name of the logger context to unregister
      */
     public static void unregisterLoggerContext(final String loggerContextName) {
+        if (isJmxDisabled()) {
+            LOGGER.debug("JMX disabled for Log4j2. Not unregistering MBeans.");
+            return;
+        }
         final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         unregisterLoggerContext(loggerContextName, mbs);
     }


[24/42] logging-log4j2 git commit: [LOG4J2-1540] The Core AbstractManager should track its LoggerContext. All appenders created with a Configuration object in their respective factories now pass that configuration's logger context to the managers they cr

Posted by rp...@apache.org.
[LOG4J2-1540] The Core AbstractManager should track its LoggerContext.
All appenders created with a Configuration object in their respective
factories now pass that configuration's logger context to the managers
they create. If an appender is not given a Configuration, it cannot set
the logger context for its manager and it will be null.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 722590956277af42d00089c67ca72a52c446a7b4
Parents: da5d6f3
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 08:08:10 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 08:08:10 2016 -0700

----------------------------------------------------------------------
 .../log4j/core/appender/AbstractManager.java    | 17 ++++++-
 .../core/appender/ConfigurationFactoryData.java | 50 ++++++++++++++++++++
 .../log4j/core/appender/FileAppender.java       | 12 ++---
 .../log4j/core/appender/FileManager.java        | 30 +++++++-----
 .../core/appender/OutputStreamManager.java      | 12 ++---
 .../core/appender/RandomAccessFileAppender.java |  2 +-
 .../core/appender/RandomAccessFileManager.java  | 27 ++++++-----
 .../core/appender/RollingFileAppender.java      | 16 +++----
 .../RollingRandomAccessFileAppender.java        |  2 +-
 .../log4j/core/appender/WriterManager.java      |  2 +-
 .../appender/db/AbstractDatabaseManager.java    |  2 +-
 .../log4j/core/appender/mom/JmsManager.java     |  2 +-
 .../core/appender/mom/jeromq/JeroMqManager.java |  2 +-
 .../core/appender/mom/kafka/KafkaManager.java   |  2 +-
 .../appender/rolling/RollingFileManager.java    | 35 +++++++-------
 .../rolling/RollingRandomAccessFileManager.java | 32 ++++++++-----
 .../logging/log4j/core/net/JndiManager.java     |  2 +-
 .../logging/log4j/core/net/SmtpManager.java     |  2 +-
 .../appender/RandomAccessFileManagerTest.java   | 18 +++----
 .../rolling/OnStartupTriggeringPolicyTest.java  |  2 +-
 .../RollingRandomAccessFileManagerTest.java     | 24 +++++-----
 .../flume/appender/AbstractFlumeManager.java    |  2 +-
 src/changes/changes.xml                         |  3 ++
 23 files changed, 192 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/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 4c78e7f..4d7fc69 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
@@ -23,6 +23,7 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.status.StatusLogger;
 
@@ -48,8 +49,11 @@ public abstract class AbstractManager {
     protected int count;
 
     private final String name;
+    
+    private final LoggerContext loggerContext;
 
-    protected AbstractManager(final String name) {
+    protected AbstractManager(final LoggerContext loggerContext, final String name) {
+        this.loggerContext = loggerContext;
         this.name = name;
         LOGGER.debug("Starting {} {}", this.getClass().getSimpleName(), name);
     }
@@ -117,6 +121,17 @@ public abstract class AbstractManager {
     }
 
     /**
+     * Gets the logger context used to create this instance or null. The logger context is usually set when an appender
+     * creates a manager and that appender is given a Configuration. Not all appenders are given a Configuration by
+     * their factory method or builder.
+     * 
+     * @return the logger context used to create this instance or null.
+     */
+    public LoggerContext getLoggerContext() {
+        return loggerContext;
+    }
+
+    /**
      * Called to signify that this Manager is no longer required by an Appender.
      */
     public void release() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConfigurationFactoryData.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConfigurationFactoryData.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConfigurationFactoryData.java
new file mode 100644
index 0000000..e2c20d4
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConfigurationFactoryData.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender;
+
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+
+/**
+ * Factory Data that carries a configuration.
+ */
+public class ConfigurationFactoryData {
+
+    /**
+     * This field is public to follow the style of existing FactoryData classes.
+     */
+    public final Configuration configuration;
+
+    public ConfigurationFactoryData(Configuration configuration) {
+        super();
+        this.configuration = configuration;
+    }
+
+    public Configuration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * Gets the LoggerContext from the Configuration or null.
+     * 
+     * @return the LoggerContext from the Configuration or null.
+     */
+    public LoggerContext getLoggerContext() {
+        return configuration != null ? configuration.getLoggerContext() : null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
index 736714d..b42f9da 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
@@ -73,7 +73,7 @@ public final class FileAppender extends AbstractOutputStreamAppender<FileManager
         private boolean createOnDemand;
 
         @PluginConfiguration
-        private Configuration config;
+        private Configuration configuration;
 
         @Override
         public FileAppender build() {
@@ -87,13 +87,13 @@ public final class FileAppender extends AbstractOutputStreamAppender<FileManager
             Layout<? extends Serializable> layout = getOrCreateLayout();
 
             final FileManager manager = FileManager.getFileManager(fileName, append, locking, bufferedIo, createOnDemand,
-                    advertiseUri, layout, bufferSize, isImmediateFlush());
+                    advertiseUri, layout, bufferSize, isImmediateFlush(), configuration);
             if (manager == null) {
                 return null;
             }
 
             return new FileAppender(getName(), layout, getFilter(), manager, fileName, isIgnoreExceptions(),
-                    !bufferedIo || isImmediateFlush(), advertise ? config.getAdvertiser() : null);
+                    !bufferedIo || isImmediateFlush(), advertise ? configuration.getAdvertiser() : null);
         }
 
         public String getAdvertiseUri() {
@@ -104,8 +104,8 @@ public final class FileAppender extends AbstractOutputStreamAppender<FileManager
             return bufferSize;
         }
 
-        public Configuration getConfig() {
-            return config;
+        public Configuration getConfiguration() {
+            return configuration;
         }
 
         public String getFileName() {
@@ -158,7 +158,7 @@ public final class FileAppender extends AbstractOutputStreamAppender<FileManager
         }
 
         public B withConfiguration(final Configuration config) {
-            this.config = config;
+            this.configuration = config;
             return asBuilder();
         }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
index 2b9024b..33a2300 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
@@ -29,6 +29,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.util.Constants;
 
 
@@ -72,13 +74,12 @@ public class FileManager extends OutputStreamManager {
     }
 
     /** 
-     * @throws IOException 
      * @since 2.7 
      */
-    protected FileManager(final String fileName, final OutputStream os, final boolean append, final boolean locking, final boolean createOnDemand,
-            final String advertiseURI, final Layout<? extends Serializable> layout, final boolean writeHeader,
-            final ByteBuffer buffer) throws IOException {
-        super(os, fileName, createOnDemand, layout, writeHeader, buffer);
+    protected FileManager(LoggerContext loggerContext, final String fileName, final OutputStream os, final boolean append, final boolean locking,
+            final boolean createOnDemand, final String advertiseURI, final Layout<? extends Serializable> layout,
+            final boolean writeHeader, final ByteBuffer buffer) {
+        super(loggerContext, os, fileName, createOnDemand, layout, writeHeader, buffer);
         this.isAppend = append;
         this.createOnDemand = createOnDemand;
         this.isLocking = locking;
@@ -97,18 +98,19 @@ public class FileManager extends OutputStreamManager {
      * @param layout The layout
      * @param bufferSize buffer size for buffered IO
      * @param immediateFlush true if the contents should be flushed on every write, false otherwise.
+     * @param configuration The configuration.
      * @return A FileManager for the File.
      */
     public static FileManager getFileManager(final String fileName, final boolean append, boolean locking,
             final boolean bufferedIo, final boolean createOnDemand, final String advertiseUri,
-            final Layout<? extends Serializable> layout, final int bufferSize, final boolean immediateFlush) {
+            final Layout<? extends Serializable> layout, final int bufferSize, final boolean immediateFlush,
+            Configuration configuration) {
 
         if (locking && bufferedIo) {
             locking = false;
         }
-        return (FileManager) getManager(fileName,
-                new FactoryData(append, locking, bufferedIo, bufferSize, immediateFlush, createOnDemand, advertiseUri, layout),
-                FACTORY);
+        return (FileManager) getManager(fileName, new FactoryData(append, locking, bufferedIo, bufferSize,
+                immediateFlush, createOnDemand, advertiseUri, layout, configuration), FACTORY);
     }
 
     @Override
@@ -198,7 +200,7 @@ public class FileManager extends OutputStreamManager {
     /**
      * Factory Data.
      */
-    private static class FactoryData {
+    private static class FactoryData extends ConfigurationFactoryData {
         private final boolean append;
         private final boolean locking;
         private final boolean bufferedIO;
@@ -218,10 +220,12 @@ public class FileManager extends OutputStreamManager {
          * @param createOnDemand if you want to lazy-create the file (a.k.a. on-demand.)
          * @param advertiseURI the URI to use when advertising the file
          * @param layout The layout
+         * @param configuration the configuration
          */
         public FactoryData(final boolean append, final boolean locking, final boolean bufferedIO, final int bufferSize,
                 final boolean immediateFlush, final boolean createOnDemand, final String advertiseURI,
-                final Layout<? extends Serializable> layout) {
+                final Layout<? extends Serializable> layout, Configuration configuration) {
+            super(configuration);
             this.append = append;
             this.locking = locking;
             this.bufferedIO = bufferedIO;
@@ -257,8 +261,8 @@ public class FileManager extends OutputStreamManager {
                 final int actualSize = data.bufferedIO ? data.bufferSize : Constants.ENCODER_BYTE_BUFFER_SIZE;
                 final ByteBuffer buffer = ByteBuffer.wrap(new byte[actualSize]);
                 final FileOutputStream fos = data.createOnDemand ? null : new FileOutputStream(file, data.append);
-                return new FileManager(name, fos, data.append, data.locking, data.createOnDemand, data.advertiseURI, data.layout,
-                        writeHeader, buffer);
+                return new FileManager(data.getLoggerContext(), name, fos, data.append, data.locking,
+                        data.createOnDemand, data.advertiseURI, data.layout, writeHeader, buffer);
             } catch (final IOException ex) {
                 LOGGER.error("FileManager (" + name + ") " + ex, ex);
             }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
index e5960ee..698409a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
@@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
 import java.util.Objects;
 
 import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.layout.ByteBufferDestination;
 import org.apache.logging.log4j.core.util.Constants;
 
@@ -49,7 +50,7 @@ public class OutputStreamManager extends AbstractManager implements ByteBufferDe
     @Deprecated
     protected OutputStreamManager(final OutputStream os, final String streamName, final Layout<?> layout,
             final boolean writeHeader, final ByteBuffer byteBuffer) {
-        super(streamName);
+        super(null, streamName);
         this.os = os;
         this.layout = layout;
         if (writeHeader && layout != null) {
@@ -66,13 +67,12 @@ public class OutputStreamManager extends AbstractManager implements ByteBufferDe
     }
 
     /**
-     * @throws IOException 
      * @since 2.7
      */
-    protected OutputStreamManager(OutputStream os, final String streamName, final boolean createOnDemand,
-            final Layout<? extends Serializable> layout, final boolean writeHeader, final ByteBuffer byteBuffer)
-            throws IOException {
-        super(streamName);
+    protected OutputStreamManager(final LoggerContext loggerContext, OutputStream os, final String streamName,
+            final boolean createOnDemand, final Layout<? extends Serializable> layout, final boolean writeHeader,
+            final ByteBuffer byteBuffer) {
+        super(loggerContext, streamName);
         if (createOnDemand && os != null) {
             LOGGER.error(
                     "Invalid OutputStreamManager configuration for '{}': You cannot both set the OutputStream and request on-demand.",

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppender.java
index 738816d..543c702 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppender.java
@@ -164,7 +164,7 @@ public final class RandomAccessFileAppender extends AbstractOutputStreamAppender
             layout = PatternLayout.createDefaultLayout();
         }
         final RandomAccessFileManager manager = RandomAccessFileManager.getFileManager(
-                fileName, isAppend, isFlush, bufferSize, advertiseURI, layout
+                fileName, isAppend, isFlush, bufferSize, advertiseURI, layout, null
         );
         if (manager == null) {
             return null;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileManager.java
index c87bdf3..7ab0fe3 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RandomAccessFileManager.java
@@ -26,6 +26,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.util.NullOutputStream;
 
 /**
@@ -42,10 +44,10 @@ public class RandomAccessFileManager extends OutputStreamManager {
     private final RandomAccessFile randomAccessFile;
     private final ThreadLocal<Boolean> isEndOfBatch = new ThreadLocal<>();
 
-    protected RandomAccessFileManager(final RandomAccessFile file,
-            final String fileName, final OutputStream os, final int bufferSize,
-            final String advertiseURI, final Layout<? extends Serializable> layout, final boolean writeHeader) {
-        super(os, fileName, layout, writeHeader, ByteBuffer.wrap(new byte[bufferSize]));
+    protected RandomAccessFileManager(LoggerContext loggerContext, final RandomAccessFile file, final String fileName,
+            final OutputStream os, final int bufferSize, final String advertiseURI,
+            final Layout<? extends Serializable> layout, final boolean writeHeader) {
+        super(loggerContext, os, fileName, false, layout, writeHeader, ByteBuffer.wrap(new byte[bufferSize]));
         this.randomAccessFile = file;
         this.advertiseURI = advertiseURI;
         this.isEndOfBatch.set(Boolean.FALSE);
@@ -62,13 +64,14 @@ public class RandomAccessFileManager extends OutputStreamManager {
      * @param bufferSize The buffer size.
      * @param advertiseURI the URI to use when advertising the file
      * @param layout The layout.
+     * @param configuration The configuration.
      * @return A RandomAccessFileManager for the File.
      */
     public static RandomAccessFileManager getFileManager(final String fileName, final boolean append,
             final boolean isFlush, final int bufferSize, final String advertiseURI,
-            final Layout<? extends Serializable> layout) {
+            final Layout<? extends Serializable> layout, Configuration configuration) {
         return (RandomAccessFileManager) getManager(fileName, new FactoryData(append,
-                isFlush, bufferSize, advertiseURI, layout), FACTORY);
+                isFlush, bufferSize, advertiseURI, layout, configuration), FACTORY);
     }
 
     public Boolean isEndOfBatch() {
@@ -140,7 +143,7 @@ public class RandomAccessFileManager extends OutputStreamManager {
     /**
      * Factory Data.
      */
-    private static class FactoryData {
+    private static class FactoryData extends ConfigurationFactoryData {
         private final boolean append;
         private final boolean immediateFlush;
         private final int bufferSize;
@@ -152,9 +155,11 @@ public class RandomAccessFileManager extends OutputStreamManager {
          *
          * @param append Append status.
          * @param bufferSize size of the buffer
+         * @param configuration The configuration.
          */
-        public FactoryData(final boolean append, final boolean immediateFlush,
-                final int bufferSize, final String advertiseURI, final Layout<? extends Serializable> layout) {
+        public FactoryData(final boolean append, final boolean immediateFlush, final int bufferSize,
+                final String advertiseURI, final Layout<? extends Serializable> layout, Configuration configuration) {
+            super(configuration);
             this.append = append;
             this.immediateFlush = immediateFlush;
             this.bufferSize = bufferSize;
@@ -197,8 +202,8 @@ public class RandomAccessFileManager extends OutputStreamManager {
                 } else {
                     raf.setLength(0);
                 }
-                return new RandomAccessFileManager(raf, name, os,
-                        data.bufferSize, data.advertiseURI, data.layout, writeHeader);
+                return new RandomAccessFileManager(data.getLoggerContext(), raf, name,
+                        os, data.bufferSize, data.advertiseURI, data.layout, writeHeader);
             } catch (final Exception ex) {
                 LOGGER.error("RandomAccessFileManager (" + name + ") " + ex, ex);
             }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
index 899ddca..f8f66f2 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
@@ -94,7 +94,7 @@ public final class RollingFileAppender extends AbstractOutputStreamAppender<Roll
         private boolean createOnDemand;
 
         @PluginConfiguration
-        private Configuration config;
+        private Configuration configuration;
 
         @Override
         public RollingFileAppender build() {
@@ -126,17 +126,17 @@ public final class RollingFileAppender extends AbstractOutputStreamAppender<Roll
 
             if (strategy == null) {
                 strategy = DefaultRolloverStrategy.createStrategy(null, null, null,
-                        String.valueOf(Deflater.DEFAULT_COMPRESSION), null, true, config);
+                        String.valueOf(Deflater.DEFAULT_COMPRESSION), null, true, configuration);
             }
 
             if (strategy == null) {
                 strategy = DefaultRolloverStrategy.createStrategy(null, null, null,
-                        String.valueOf(Deflater.DEFAULT_COMPRESSION), null, true, config);
+                        String.valueOf(Deflater.DEFAULT_COMPRESSION), null, true, configuration);
             }
 
             final RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, append,
                     bufferedIo, policy, strategy, advertiseUri, getLayout(), bufferSize, isImmediateFlush(),
-                    createOnDemand);
+                    createOnDemand, configuration);
             if (manager == null) {
                 return null;
             }
@@ -144,7 +144,7 @@ public final class RollingFileAppender extends AbstractOutputStreamAppender<Roll
             manager.initialize();
 
             return new RollingFileAppender(getName(), getLayout(), getFilter(), manager, fileName, filePattern,
-                    isIgnoreExceptions(), isImmediateFlush(), advertise ? config.getAdvertiser() : null);
+                    isIgnoreExceptions(), isImmediateFlush(), advertise ? configuration.getAdvertiser() : null);
         }
 
         public String getAdvertiseUri() {
@@ -155,8 +155,8 @@ public final class RollingFileAppender extends AbstractOutputStreamAppender<Roll
             return bufferSize;
         }
 
-        public Configuration getConfig() {
-            return config;
+        public Configuration getConfiguration() {
+            return configuration;
         }
 
         public String getFileName() {
@@ -209,7 +209,7 @@ public final class RollingFileAppender extends AbstractOutputStreamAppender<Roll
         }
 
         public B withConfiguration(final Configuration config) {
-            this.config = config;
+            this.configuration = config;
             return asBuilder();
         }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppender.java
index 67777e6..5e6f9c7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppender.java
@@ -205,7 +205,7 @@ public final class RollingRandomAccessFileAppender extends AbstractOutputStreamA
         }
 
         final RollingRandomAccessFileManager manager = RollingRandomAccessFileManager.getRollingRandomAccessFileManager(
-                fileName, filePattern, isAppend, isFlush, bufferSize, policy, strategy, advertiseURI, layout);
+                fileName, filePattern, isAppend, isFlush, bufferSize, policy, strategy, advertiseURI, layout, config);
         if (manager == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/WriterManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/WriterManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/WriterManager.java
index 11ac856..b3b9e73 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/WriterManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/WriterManager.java
@@ -46,7 +46,7 @@ public class WriterManager extends AbstractManager {
 
     public WriterManager(final Writer writer, final String streamName, final StringLayout layout,
             final boolean writeHeader) {
-        super(streamName);
+        super(null, streamName);
         this.writer = writer;
         this.layout = layout;
         if (writeHeader && layout != null) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java
index 82c7b18..c3682dc 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java
@@ -41,7 +41,7 @@ public abstract class AbstractDatabaseManager extends AbstractManager implements
      * @param bufferSize The size of the log event buffer.
      */
     protected AbstractDatabaseManager(final String name, final int bufferSize) {
-        super(name);
+        super(null, name);
         this.bufferSize = bufferSize;
         this.buffer = new ArrayList<>(bufferSize + 1);
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsManager.java
index f5f42c9..7cf1637 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsManager.java
@@ -52,7 +52,7 @@ public class JmsManager extends AbstractManager {
     private JmsManager(final String name, final JndiManager jndiManager, final String connectionFactoryName,
                        final String destinationName, final String username, final String password)
         throws NamingException, JMSException {
-        super(name);
+        super(null, name);
         this.jndiManager = jndiManager;
         final ConnectionFactory connectionFactory = this.jndiManager.lookup(connectionFactoryName);
         if (username != null && password != null) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqManager.java
index e84ab6d..6f106be 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqManager.java
@@ -69,7 +69,7 @@ public class JeroMqManager extends AbstractManager {
     private final ZMQ.Socket publisher;
 
     private JeroMqManager(final String name, final JeroMqConfiguration config) {
-        super(name);
+        super(null, name);
         publisher = CONTEXT.socket(ZMQ.PUB);
         publisher.setAffinity(config.affinity);
         publisher.setBacklog(config.backlog);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/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 d535e02..f222b59 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
@@ -44,7 +44,7 @@ public class KafkaManager extends AbstractManager {
     private final String topic;
 
     public KafkaManager(final String name, final String topic, final Property[] properties) {
-        super(name);
+        super(null, name);
         this.topic = topic;
         config.setProperty("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
         config.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
index 3c6739f..b741b4e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
@@ -17,7 +17,6 @@
 package org.apache.logging.log4j.core.appender.rolling;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -28,11 +27,13 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 
 import org.apache.logging.log4j.core.Layout;
 import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.ConfigurationFactoryData;
 import org.apache.logging.log4j.core.appender.FileManager;
 import org.apache.logging.log4j.core.appender.ManagerFactory;
 import org.apache.logging.log4j.core.appender.rolling.action.AbstractAction;
 import org.apache.logging.log4j.core.appender.rolling.action.Action;
-import org.apache.logging.log4j.core.util.Clock;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.util.Constants;
 import org.apache.logging.log4j.core.util.Log4jThread;
 
@@ -81,15 +82,13 @@ public class RollingFileManager extends FileManager {
     }
 
     /**
-     * @throws IOException 
      * @since 2.7
      */
-    protected RollingFileManager(final String fileName, final String pattern, final OutputStream os, final boolean append,
-            final boolean createOnDemand, final long size, final long time, final TriggeringPolicy triggeringPolicy,
-            final RolloverStrategy rolloverStrategy, final String advertiseURI,
-            final Layout<? extends Serializable> layout, final boolean writeHeader, final ByteBuffer buffer)
-            throws IOException {
-        super(fileName, os, append, false, createOnDemand, advertiseURI, layout, writeHeader, buffer);
+    protected RollingFileManager(LoggerContext loggerContext, final String fileName, final String pattern, final OutputStream os,
+            final boolean append, final boolean createOnDemand, final long size, final long time,
+            final TriggeringPolicy triggeringPolicy, final RolloverStrategy rolloverStrategy,
+            final String advertiseURI, final Layout<? extends Serializable> layout, final boolean writeHeader, final ByteBuffer buffer) {
+        super(loggerContext, fileName, os, append, false, createOnDemand, advertiseURI, layout, writeHeader, buffer);
         this.size = size;
         this.initialTime = time;
         this.triggeringPolicy = triggeringPolicy;
@@ -115,15 +114,16 @@ public class RollingFileManager extends FileManager {
      * @param bufferSize buffer size to use if bufferedIO is true
      * @param immediateFlush flush on every write or not
      * @param createOnDemand true if you want to lazy-create the file (a.k.a. on-demand.)
+     * @param configuration The configuration.
      * @return A RollingFileManager.
      */
     public static RollingFileManager getFileManager(final String fileName, final String pattern, final boolean append,
             final boolean bufferedIO, final TriggeringPolicy policy, final RolloverStrategy strategy,
             final String advertiseURI, final Layout<? extends Serializable> layout, final int bufferSize,
-            final boolean immediateFlush, final boolean createOnDemand) {
+            final boolean immediateFlush, final boolean createOnDemand, final Configuration configuration) {
 
         return (RollingFileManager) getManager(fileName, new FactoryData(pattern, append,
-            bufferedIO, policy, strategy, advertiseURI, layout, bufferSize, immediateFlush, createOnDemand), factory);
+            bufferedIO, policy, strategy, advertiseURI, layout, bufferSize, immediateFlush, createOnDemand, configuration), factory);
     }
 
     // override to make visible for unit tests
@@ -341,7 +341,7 @@ public class RollingFileManager extends FileManager {
     /**
      * Factory data.
      */
-    private static class FactoryData {
+    private static class FactoryData extends ConfigurationFactoryData {
         private final String pattern;
         private final boolean append;
         private final boolean bufferedIO;
@@ -354,7 +354,7 @@ public class RollingFileManager extends FileManager {
         private final Layout<? extends Serializable> layout;
 
         /**
-         * Create the data for the factory.
+         * Creates the data for the factory.
          * @param pattern The pattern.
          * @param append The append flag.
          * @param bufferedIO The bufferedIO flag.
@@ -363,11 +363,13 @@ public class RollingFileManager extends FileManager {
          * @param bufferSize the buffer size
          * @param immediateFlush flush on every write or not
          * @param createOnDemand true if you want to lazy-create the file (a.k.a. on-demand.)
+         * @param configuration The configuration
          */
         public FactoryData(final String pattern, final boolean append, final boolean bufferedIO,
                 final TriggeringPolicy policy, final RolloverStrategy strategy, final String advertiseURI,
                 final Layout<? extends Serializable> layout, final int bufferSize, final boolean immediateFlush, 
-                final boolean createOnDemand) {
+                final boolean createOnDemand, final Configuration configuration) {
+            super(configuration);
             this.pattern = pattern;
             this.append = append;
             this.bufferedIO = bufferedIO;
@@ -458,8 +460,9 @@ public class RollingFileManager extends FileManager {
                 final OutputStream os = data.createOnDemand ? null : new FileOutputStream(name, data.append);
                 final long time = data.createOnDemand? System.currentTimeMillis() : file.lastModified(); // LOG4J2-531 create file first so time has valid value
                 
-                return new RollingFileManager(name, data.pattern, os, data.append, data.createOnDemand, size, time, data.policy,
-                        data.strategy, data.advertiseURI, data.layout, writeHeader, buffer);
+                return new RollingFileManager(data.getLoggerContext(), name, data.pattern, os,
+                        data.append, data.createOnDemand, size, time, data.policy, data.strategy, data.advertiseURI,
+                        data.layout, writeHeader, buffer);
             } catch (final IOException ex) {
                 LOGGER.error("RollingFileManager (" + name + ") " + ex, ex);
             }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java
index 4a92beb..8b39209 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java
@@ -24,8 +24,11 @@ import java.io.Serializable;
 import java.nio.ByteBuffer;
 
 import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.AppenderLoggingException;
+import org.apache.logging.log4j.core.appender.ConfigurationFactoryData;
 import org.apache.logging.log4j.core.appender.ManagerFactory;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.util.NullOutputStream;
 
 /**
@@ -43,12 +46,13 @@ public class RollingRandomAccessFileManager extends RollingFileManager {
     private RandomAccessFile randomAccessFile;
     private final ThreadLocal<Boolean> isEndOfBatch = new ThreadLocal<>();
 
-    public RollingRandomAccessFileManager(final RandomAccessFile raf, final String fileName, final String pattern,
-            final OutputStream os, final boolean append, final boolean immediateFlush, final int bufferSize,
-            final long size, final long time, final TriggeringPolicy policy, final RolloverStrategy strategy,
-            final String advertiseURI, final Layout<? extends Serializable> layout, final boolean writeHeader) {
-        super(fileName, pattern, os, append, size, time, policy, strategy, advertiseURI, layout, writeHeader,
-                ByteBuffer.wrap(new byte[bufferSize]));
+    public RollingRandomAccessFileManager(final LoggerContext loggerContext, final RandomAccessFile raf,
+            final String fileName, final String pattern, final OutputStream os, final boolean append,
+            final boolean immediateFlush, final int bufferSize, final long size, final long time,
+            final TriggeringPolicy policy, final RolloverStrategy strategy, final String advertiseURI,
+            final Layout<? extends Serializable> layout, final boolean writeHeader) {
+        super(loggerContext, fileName, pattern, os, append, false, size, time, policy, strategy, advertiseURI, layout,
+                writeHeader, ByteBuffer.wrap(new byte[bufferSize]));
         this.randomAccessFile = raf;
         isEndOfBatch.set(Boolean.FALSE);
         writeHeader();
@@ -78,9 +82,9 @@ public class RollingRandomAccessFileManager extends RollingFileManager {
     public static RollingRandomAccessFileManager getRollingRandomAccessFileManager(final String fileName,
             final String filePattern, final boolean isAppend, final boolean immediateFlush, final int bufferSize,
             final TriggeringPolicy policy, final RolloverStrategy strategy, final String advertiseURI,
-            final Layout<? extends Serializable> layout) {
+            final Layout<? extends Serializable> layout, Configuration configuration) {
         return (RollingRandomAccessFileManager) getManager(fileName, new FactoryData(filePattern, isAppend,
-                immediateFlush, bufferSize, policy, strategy, advertiseURI, layout), FACTORY);
+                immediateFlush, bufferSize, policy, strategy, advertiseURI, layout, configuration), FACTORY);
     }
 
     public Boolean isEndOfBatch() {
@@ -182,9 +186,9 @@ public class RollingRandomAccessFileManager extends RollingFileManager {
                     LOGGER.trace("RandomAccessFile {} set length to 0", name);
                     raf.setLength(0);
                 }
-                return new RollingRandomAccessFileManager(raf, name, data.pattern, NullOutputStream.NULL_OUTPUT_STREAM,
-                        data.append, data.immediateFlush, data.bufferSize, size, time, data.policy, data.strategy,
-                        data.advertiseURI, data.layout, writeHeader);
+                return new RollingRandomAccessFileManager(data.getLoggerContext(), raf, name, data.pattern,
+                        NullOutputStream.NULL_OUTPUT_STREAM, data.append, data.immediateFlush, data.bufferSize, size, time, data.policy,
+                        data.strategy, data.advertiseURI, data.layout, writeHeader);
             } catch (final IOException ex) {
                 LOGGER.error("Cannot access RandomAccessFile " + ex, ex);
                 if (raf != null) {
@@ -202,7 +206,7 @@ public class RollingRandomAccessFileManager extends RollingFileManager {
     /**
      * Factory data.
      */
-    private static class FactoryData {
+    private static class FactoryData extends ConfigurationFactoryData {
         private final String pattern;
         private final boolean append;
         private final boolean immediateFlush;
@@ -223,10 +227,12 @@ public class RollingRandomAccessFileManager extends RollingFileManager {
          * @param strategy
          * @param advertiseURI
          * @param layout
+         * @param configuration
          */
         public FactoryData(final String pattern, final boolean append, final boolean immediateFlush,
                 final int bufferSize, final TriggeringPolicy policy, final RolloverStrategy strategy,
-                final String advertiseURI, final Layout<? extends Serializable> layout) {
+                final String advertiseURI, final Layout<? extends Serializable> layout, Configuration configuration) {
+            super(configuration);
             this.pattern = pattern;
             this.append = append;
             this.immediateFlush = immediateFlush;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
index 31009b6..c413373 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
@@ -39,7 +39,7 @@ public class JndiManager extends AbstractManager {
     private final Context context;
 
     private JndiManager(final String name, final Context context) {
-        super(name);
+        super(null, name);
         this.context = context;
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
index 5367fa3..5494911 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
@@ -77,7 +77,7 @@ public class SmtpManager extends AbstractManager {
 
     protected SmtpManager(final String name, final Session session, final MimeMessage message,
                           final FactoryData data) {
-        super(name);
+        super(null, name);
         this.session = session;
         this.message = message;
         this.data = data;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
index ac95668..fb84266 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
@@ -47,8 +47,8 @@ public class RandomAccessFileManagerTest {
         final File file = folder.newFile();
         try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
-            final RandomAccessFileManager manager = new RandomAccessFileManager(raf, file.getName(), os,
-                    RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, true);
+            final RandomAccessFileManager manager = new RandomAccessFileManager(null, raf, file.getName(),
+                    os, RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, true);
 
             final int size = RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3;
             final byte[] data = new byte[size];
@@ -68,8 +68,8 @@ public class RandomAccessFileManagerTest {
         final File file = folder.newFile();
         try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
-            final RandomAccessFileManager manager = new RandomAccessFileManager(raf, file.getName(), os,
-                    RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, true);
+            final RandomAccessFileManager manager = new RandomAccessFileManager(null, raf, file.getName(),
+                    os, RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, true);
 
             final int size = RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3 + 1;
             final byte[] data = new byte[size];
@@ -89,8 +89,8 @@ public class RandomAccessFileManagerTest {
             final int bufferSize = 4 * 1024;
             assertNotEquals(bufferSize, RandomAccessFileManager.DEFAULT_BUFFER_SIZE);
 
-            final RandomAccessFileManager manager = new RandomAccessFileManager(raf, file.getName(), os,
-                    bufferSize, null, null, true);
+            final RandomAccessFileManager manager = new RandomAccessFileManager(null, raf, file.getName(),
+                    os, bufferSize, null, null, true);
 
             // check the resulting buffer size is what was requested
             assertEquals(bufferSize, manager.getBufferSize());
@@ -102,8 +102,8 @@ public class RandomAccessFileManagerTest {
         try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
             final int bufferSize = 1;
-            final RandomAccessFileManager manager = new RandomAccessFileManager(raf, file.getName(), os,
-                    bufferSize, null, null, true);
+            final RandomAccessFileManager manager = new RandomAccessFileManager(null, raf, file.getName(),
+                    os, bufferSize, null, null, true);
 
             final int size = bufferSize * 3 + 1;
             final byte[] data = new byte[size];
@@ -131,7 +131,7 @@ public class RandomAccessFileManagerTest {
         assertEquals("all flushed to disk", bytes.length, file.length());
 
         final RandomAccessFileManager manager = RandomAccessFileManager.getFileManager(
-                file.getAbsolutePath(), isAppend, true, RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null);
+                file.getAbsolutePath(), isAppend, true, RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, null);
         manager.write(bytes, 0, bytes.length, true);
         final int expected = bytes.length * 2;
         assertEquals("appended, not overwritten", expected, file.length());

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
index 27f8e7e..4ab6b5b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
@@ -78,7 +78,7 @@ public class OnStartupTriggeringPolicyTest {
                 configuration);
         final OnStartupTriggeringPolicy policy = OnStartupTriggeringPolicy.createPolicy(1);
         final RollingFileManager manager = RollingFileManager.getFileManager(TARGET_FILE, TARGET_PATTERN, true, false,
-                policy, strategy, null, layout, 8192, true, false);
+                policy, strategy, null, layout, 8192, true, false, configuration);
         try {
             manager.initialize();
             String files = Arrays.toString(new File(TARGET_FOLDER).listFiles());

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
index 70f5aa1..c9486f0 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
@@ -58,9 +58,9 @@ public class RollingRandomAccessFileManagerTest {
             final long time = System.currentTimeMillis();
             final TriggeringPolicy triggerPolicy = new SizeBasedTriggeringPolicy(triggerSize);
             final RolloverStrategy rolloverStrategy = null;
-            final RollingRandomAccessFileManager manager = new RollingRandomAccessFileManager(raf, file.getName(),
-                    Strings.EMPTY, os, append, flushNow, RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE,
-                    triggerSize, time, triggerPolicy, rolloverStrategy, null, null, true);
+            final RollingRandomAccessFileManager manager = new RollingRandomAccessFileManager(null, raf,
+                    file.getName(), Strings.EMPTY, os, append, flushNow,
+                    RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE, triggerSize, time, triggerPolicy, rolloverStrategy, null, null, true);
 
             final int size = RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3;
             final byte[] data = new byte[size];
@@ -87,9 +87,9 @@ public class RollingRandomAccessFileManagerTest {
             final long time = System.currentTimeMillis();
             final TriggeringPolicy triggerPolicy = new SizeBasedTriggeringPolicy(triggerSize);
             final RolloverStrategy rolloverStrategy = null;
-            final RollingRandomAccessFileManager manager = new RollingRandomAccessFileManager(raf, file.getName(),
-                    Strings.EMPTY, os, append, flushNow, RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE,
-                    triggerSize, time, triggerPolicy, rolloverStrategy, null, null, true);
+            final RollingRandomAccessFileManager manager = new RollingRandomAccessFileManager(null, raf,
+                    file.getName(), Strings.EMPTY, os, append, flushNow,
+                    RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE, triggerSize, time, triggerPolicy, rolloverStrategy, null, null, true);
 
             final int size = RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3 + 1;
             final byte[] data = new byte[size];
@@ -115,9 +115,9 @@ public class RollingRandomAccessFileManagerTest {
             final int bufferSize = 4 * 1024;
             assertNotEquals(bufferSize, RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE);
             final RolloverStrategy rolloverStrategy = null;
-            final RollingRandomAccessFileManager manager = new RollingRandomAccessFileManager(raf, file.getName(),
-                    Strings.EMPTY, os, append, flushNow, bufferSize, triggerSize, time, triggerPolicy, rolloverStrategy,
-                    null, null, true);
+            final RollingRandomAccessFileManager manager = new RollingRandomAccessFileManager(null, raf,
+                    file.getName(), Strings.EMPTY, os, append, flushNow, bufferSize, triggerSize, time, triggerPolicy,
+                    rolloverStrategy, null, null, true);
 
             // check the resulting buffer size is what was requested
             assertEquals(bufferSize, manager.getBufferSize());
@@ -149,7 +149,7 @@ public class RollingRandomAccessFileManagerTest {
                 //
                 file.getAbsolutePath(), Strings.EMPTY, isAppend, immediateFlush,
                 RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE, new SizeBasedTriggeringPolicy(Long.MAX_VALUE), //
-                null, null, null);
+                null, null, null, null);
         manager.write(bytes, 0, bytes.length, immediateFlush);
         final int expected = bytes.length * 2;
         assertThat("appended, not overwritten", file, hasLength(expected));
@@ -171,7 +171,7 @@ public class RollingRandomAccessFileManagerTest {
                 //
                 file.getAbsolutePath(), Strings.EMPTY, isAppend, true,
                 RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE, new SizeBasedTriggeringPolicy(Long.MAX_VALUE), //
-                null, null, null);
+                null, null, null, null);
         assertTrue(manager.getFileTime() < expectedMax);
         assertTrue(manager.getFileTime() >= expectedMin);
     }
@@ -189,7 +189,7 @@ public class RollingRandomAccessFileManagerTest {
                 //
                 file.getAbsolutePath(), Strings.EMPTY, isAppend, true,
                 RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE, new SizeBasedTriggeringPolicy(Long.MAX_VALUE), //
-                null, null, null);
+                null, null, null, null);
         assertThat(file, lastModified(equalTo(manager.getFileTime())));
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/AbstractFlumeManager.java
----------------------------------------------------------------------
diff --git a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/AbstractFlumeManager.java b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/AbstractFlumeManager.java
index 55fb858..8fc6ab4 100644
--- a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/AbstractFlumeManager.java
+++ b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/AbstractFlumeManager.java
@@ -25,7 +25,7 @@ import org.apache.logging.log4j.core.appender.AbstractManager;
 public abstract class AbstractFlumeManager extends AbstractManager {
 
     public AbstractFlumeManager(final String name) {
-        super(name);
+        super(null, name);
     }
 
     public abstract void send(Event event);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72259095/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4c8303a..b170dc6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -129,6 +129,9 @@
       <action issue="LOG4J2-1547" dev="ggregory" type="add" due-to="Gary Gregory">
         The Core AbstractConfiguration should track its LoggerContext and add Configuration.getLoggerContext().
       </action>
+      <action issue="LOG4J2-1540" dev="ggregory" type="add" due-to="Gary Gregory">
+        The Core AbstractManager should track its LoggerContext.
+      </action>
       <action issue="LOG4J2-1458" dev="ggregory" type="update" due-to="Gary Gregory">
         Update Jackson from 2.7.5 to 2.8.0.
       </action>


[26/42] logging-log4j2 git commit: [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext and add Configuration.getLoggerContext(). Fix sample.

Posted by rp...@apache.org.
[LOG4J2-1547] The Core AbstractConfiguration should track its
LoggerContext and add Configuration.getLoggerContext(). Fix sample.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: e8b97fddb91fb4f5e9a8495657de7c236a725be9
Parents: aedbbba
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 08:37:32 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 08:37:32 2016 -0700

----------------------------------------------------------------------
 .../log4j/core/config/builder/CustomConfigurationFactory.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e8b97fdd/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 d4567bc..ab6bb88 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
@@ -59,7 +59,7 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
 
     @Override
     public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
-        return getConfiguration(null, source.toString(), null);
+        return getConfiguration(loggerContext, source.toString(), null);
     }
 
     @Override


[29/42] logging-log4j2 git commit: [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext and add Configuration.getLoggerContext(). Fix code example and adapt to new signature.

Posted by rp...@apache.org.
[LOG4J2-1547] The Core AbstractConfiguration should track its
LoggerContext and add Configuration.getLoggerContext(). Fix code example
and adapt to new signature.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 2cfc94b9e161b607c3c8d88bccc82f90651f61c8
Parents: 498eef5
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 08:57:23 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 08:57:23 2016 -0700

----------------------------------------------------------------------
 src/site/xdoc/manual/extending.xml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2cfc94b9/src/site/xdoc/manual/extending.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/extending.xml b/src/site/xdoc/manual/extending.xml
index d625edd..2bcdef2 100644
--- a/src/site/xdoc/manual/extending.xml
+++ b/src/site/xdoc/manual/extending.xml
@@ -123,12 +123,14 @@ public class XMLConfigurationFactory extends ConfigurationFactory {
     public static final String[] SUFFIXES = new String[] {".xml", "*"};
 
     /**
-     * Return the Configuration.
+     * Returns the Configuration.
+     * @param loggerContext The logger context.
      * @param source The InputSource.
      * @return The Configuration.
      */
-    public Configuration getConfiguration(InputSource source) {
-        return new XMLConfiguration(source, configFile);
+    @Override
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
+        return new XmlConfiguration(loggerContext, source);
     }
 
     /**


[18/42] logging-log4j2 git commit: [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext.

Posted by rp...@apache.org.
[LOG4J2-1547] The Core AbstractConfiguration should track its
LoggerContext.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 322ccf0f63128ac2f08db2d1bdb5e93bd6cb8f49
Parents: acbecc0
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 14:37:24 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 14:37:24 2016 -0700

----------------------------------------------------------------------
 .../org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java  | 4 ++--
 .../apache/logging/log4j/core/config/AbstractConfiguration.java  | 3 ++-
 .../logging/log4j/core/config/plugins/util/ResolverUtilTest.java | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/322ccf0f/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
index 667bac2..ea55dd9 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
@@ -53,8 +53,8 @@ public class Log4j1ConfigurationFactoryTest {
     private Layout<?> testFile(final String configResource) throws Exception {
         final URL configLocation = ClassLoader.getSystemResource(configResource);
         assertNotNull(configLocation);
-        final Configuration configuration = new Log4j1ConfigurationFactory().getConfiguration("test",
-                configLocation.toURI());
+        final Configuration configuration = new Log4j1ConfigurationFactory().getConfiguration(null,
+        		"test", configLocation.toURI());
         assertNotNull(configuration);
         final FileAppender appender = configuration.getAppender("File");
         assertNotNull(appender);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/322ccf0f/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
index d452396..0e053a1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
@@ -131,7 +131,8 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
      */
     protected AbstractConfiguration(LoggerContext loggerContext, final ConfigurationSource configurationSource) {
         this.loggerContext = new WeakReference<>(loggerContext);
-        //this.loggerContext = new WeakReference(Objects.requireNonNull(loggerContext, "loggerContext is null"));
+        // The loggerContext is null for the NullConfiguration class.
+        // this.loggerContext = new WeakReference(Objects.requireNonNull(loggerContext, "loggerContext is null"));
         this.configurationSource = Objects.requireNonNull(configurationSource, "configurationSource is null");
         componentMap.put(Configuration.CONTEXT_PROPERTIES, properties);
         pluginManager = new PluginManager(Node.CATEGORY);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/322ccf0f/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index f5d13eb..c0f1e3a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -200,7 +200,7 @@ public class ResolverUtilTest {
     static void createJar(URI jarURI, File workDir, File f) throws Exception {
         Map<String, String> env = new HashMap<>(); 
         env.put("create", "true");
-        URI uri = URI.create("jar:file://" + jarURI.getPath());
+        URI uri = URI.create("jar:file://" + jarURI.getRawPath());
         try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) {   
             Path path = zipfs.getPath(workDir.toPath().relativize(f.toPath()).toString());
             if (path.getParent() != null) {


[25/42] logging-log4j2 git commit: Use final.

Posted by rp...@apache.org.
Use final.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: aedbbba8c105d5951159c8702c49a279a8c40436
Parents: 7225909
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 08:32:50 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 08:32:50 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/log4j/config/Log4j1ConfigurationFactory.java | 2 +-
 .../test/java/org/apache/log4j/BasicConfigurationFactory.java    | 4 ++--
 .../apache/logging/log4j/core/config/ConfigurationFactory.java   | 2 +-
 .../logging/log4j/core/config/yaml/YamlConfigurationFactory.java | 2 +-
 .../org/apache/logging/log4j/core/BasicConfigurationFactory.java | 4 ++--
 .../log4j/core/config/builder/CustomConfigurationFactory.java    | 4 ++--
 .../logging/log4j/configuration/CustomConfigurationFactory.java  | 4 ++--
 7 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aedbbba8/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 a974ed5..0a6bf2a 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
@@ -40,7 +40,7 @@ public class Log4j1ConfigurationFactory extends ConfigurationFactory {
     private static final String[] SUFFIXES = {".properties"};
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
         final ConfigurationBuilder<BuiltConfiguration> builder;
         try (final InputStream configStream = source.getInputStream()) {
             builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(configStream);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aedbbba8/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
index aabc1c1..d231d82 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
@@ -37,12 +37,12 @@ public class BasicConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
         return new BasicConfiguration(loggerContext);
     }
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
         return new BasicConfiguration(loggerContext);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aedbbba8/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
index af19a0c..946bd5e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
@@ -225,7 +225,7 @@ public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
         return true;
     }
 
-    public abstract Configuration getConfiguration(LoggerContext loggerContext, ConfigurationSource source);
+    public abstract Configuration getConfiguration(final LoggerContext loggerContext, ConfigurationSource source);
 
     /**
      * Returns the Configuration.

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aedbbba8/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
index 5d7b1f5..b4beb45 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
@@ -59,7 +59,7 @@ public class YamlConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
         if (!isActive) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aedbbba8/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
index 6c6f56a..d028921 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
 public class BasicConfigurationFactory extends ConfigurationFactory {
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
         return new BasicConfiguration();
     }
 
@@ -41,7 +41,7 @@ public class BasicConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aedbbba8/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 126b0f9..d4567bc 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
@@ -58,12 +58,12 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
         return getConfiguration(null, source.toString(), null);
     }
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
         final ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder();
         return addTestFixtures(name, builder);
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aedbbba8/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
index 642abe4..53b70c7 100644
--- a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
+++ b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
@@ -43,12 +43,12 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
      * @return The Configuration.
      */
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
         return new CustomConfiguration(loggerContext, source);
     }
 
     @Override
-    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
         return new CustomConfiguration(loggerContext);
     }
 


[12/42] logging-log4j2 git commit: [LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not supported. Tweaks.

Posted by rp...@apache.org.
[LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not
supported. Tweaks.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: e0330275af40bd7e36b085ff03e108e9c5ed886c
Parents: 4157ef8
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 13:16:52 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 13:16:52 2016 -0700

----------------------------------------------------------------------
 .../log4j/core/config/plugins/util/ResolverUtilTest.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e0330275/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index 76ab740..92e6ee9 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -182,18 +182,18 @@ public class ResolverUtilTest {
     static File compile(String suffix) throws IOException {
         final File orig = new File("target/test-classes/customplugin/FixedStringLayout.java.source");
         final File workDir = new File("target/resolverutil" + suffix);
-        final File javaFile = new File(workDir, "customplugin" + suffix + "/FixedString" + suffix + "Layout.java");
-        final File parent = javaFile.getParentFile();
+        final File f = new File(workDir, "customplugin" + suffix + "/FixedString" + suffix + "Layout.java");
+        final File parent = f.getParentFile();
         if (!parent.exists()) {
-          assertTrue("Create customplugin" + suffix + " folder KO", javaFile.getParentFile().mkdirs());
+          assertTrue("Create customplugin" + suffix + " folder KO", f.getParentFile().mkdirs());
         }
   
         String content = new String(Files.readAllBytes(orig.toPath()))
           .replaceAll("FixedString", "FixedString" + suffix)
           .replaceAll("customplugin", "customplugin" + suffix);
-        Files.write(javaFile.toPath(), content.getBytes());
+        Files.write(f.toPath(), content.getBytes());
   
-        PluginManagerPackagesTest.compile(javaFile);
+        PluginManagerPackagesTest.compile(f);
         return workDir;
     }
 


[14/42] logging-log4j2 git commit: Support FileAppender

Posted by rp...@apache.org.
Support FileAppender


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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 3aceb2a327bdade228ec15662bce4cf541f82239
Parents: fadd676
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Thu Aug 25 22:29:08 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Thu Aug 25 22:29:08 2016 +0200

----------------------------------------------------------------------
 .../log4j/config/Log4j1ConfigurationParser.java | 48 ++++++++++++++++++--
 .../config/Log4j1ConfigurationFactoryTest.java  | 25 +++++++++-
 ...g4j-console-EnhancedPatternLayout.properties |  1 -
 .../log4j-console-HtmlLayout.properties         |  1 -
 .../log4j-console-PatternLayout.properties      |  1 -
 .../log4j-console-SimpleLayout.properties       |  1 -
 .../log4j-console-TTCCLayout.properties         |  1 -
 .../log4j-console-XmlLayout.properties          |  1 -
 .../log4j-file-SimpleLayout.properties          | 17 +++++++
 9 files changed, 83 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
index 11f7f76..84b8533 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
@@ -19,6 +19,7 @@ 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.ComponentBuilder;
 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;
@@ -126,6 +127,9 @@ public class Log4j1ConfigurationParser {
         case "org.apache.log4j.ConsoleAppender":
             buildConsoleAppender(appenderName);
             break;
+        case "org.apache.log4j.FileAppender":
+            buildFileAppender(appenderName);
+            break;
         default:
             reportWarning("Unknown appender class: " + appenderClass + "; ignoring appender: " + appenderName);
         }
@@ -151,16 +155,46 @@ public class Log4j1ConfigurationParser {
                 appenderBuilder.addAttribute("target", target);
             }
         }
-        buildAppenderAttribute(appenderName, appenderBuilder, "Follow", "false", "follow");
+        buildAttribute(appenderName, appenderBuilder, "Follow", "follow");
+        if ("false".equalsIgnoreCase(getLog4jAppenderValue(appenderName, "ImmediateFlush"))) {
+            reportWarning("ImmediateFlush=false is not supported on Console appender");
+        }
         buildAppenderLayout(appenderName, appenderBuilder);
         builder.add(appenderBuilder);
     }
 
-    private void buildAppenderAttribute(String appenderName, AppenderComponentBuilder appenderBuilder,
-                                        String sourceAttributeName, String defaultValue, String targetAttributeName) {
-        final String attributeValue = getLog4jAppenderValue(appenderName, sourceAttributeName, defaultValue);
+    private void buildFileAppender(final String appenderName) {
+        final AppenderComponentBuilder appenderBuilder = builder.newAppender(appenderName, "File");
+        buildMandatoryAttribute(appenderName, appenderBuilder, "File", "fileName");
+        buildAttribute(appenderName, appenderBuilder, "Append", "append");
+        buildAttribute(appenderName, appenderBuilder, "BufferedIO", "bufferedIo");
+        buildAttribute(appenderName, appenderBuilder, "BufferSize", "bufferSize");
+        buildAttribute(appenderName, appenderBuilder, "ImmediateFlush", "immediateFlush");
+        buildAppenderLayout(appenderName, appenderBuilder);
+        builder.add(appenderBuilder);
+    }
+
+    private void buildAttribute(String componentName, ComponentBuilder componentBuilder,
+                                String sourceAttributeName, String targetAttributeName) {
+        final String attributeValue = getLog4jAppenderValue(componentName, sourceAttributeName);
+        if (attributeValue != null) {
+            componentBuilder.addAttribute(targetAttributeName, attributeValue);
+        }
+    }
+
+    private void buildAttributeWithDefault(String componentName, ComponentBuilder componentBuilder,
+                                           String sourceAttributeName, String targetAttributeName, String defaultValue) {
+        final String attributeValue = getLog4jAppenderValue(componentName, sourceAttributeName, defaultValue);
+        componentBuilder.addAttribute(targetAttributeName, attributeValue);
+    }
+
+    private void buildMandatoryAttribute(String componentName, ComponentBuilder componentBuilder,
+                                         String sourceAttributeName, String targetAttributeName) {
+        final String attributeValue = getLog4jAppenderValue(componentName, sourceAttributeName);
         if (attributeValue != null) {
-            appenderBuilder.addAttribute(targetAttributeName, attributeValue);
+            componentBuilder.addAttribute(targetAttributeName, attributeValue);
+        } else {
+            reportWarning("Missing " + sourceAttributeName + " for " + componentName);
         }
     }
 
@@ -273,6 +307,10 @@ public class Log4j1ConfigurationParser {
 
     }
 
+    private String getLog4jAppenderValue(final String appenderName, final String attributeName) {
+        return properties.getProperty("log4j.appender." + appenderName + "." + attributeName);
+    }
+
     private String getLog4jAppenderValue(final String appenderName, final String attributeName,
                                          final String defaultValue) {
         return properties.getProperty("log4j.appender." + appenderName + "." + attributeName, defaultValue);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
index 9f34563..43d7b14 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
@@ -23,6 +23,7 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Layout;
 import org.apache.logging.log4j.core.appender.ConsoleAppender;
 import org.apache.logging.log4j.core.appender.ConsoleAppender.Target;
+import org.apache.logging.log4j.core.appender.FileAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.LoggerConfig;
 import org.apache.logging.log4j.core.layout.HtmlLayout;
@@ -41,8 +42,6 @@ public class Log4j1ConfigurationFactoryTest {
         assertNotNull(configuration);
         final ConsoleAppender appender = configuration.getAppender("Console");
         assertNotNull(appender);
-        // Can't set ImmediateFlush for a Console Appender in Log4j 2 like you can in 1.2
-        assertTrue(appender.getImmediateFlush());
         assertEquals(Target.SYSTEM_ERR, appender.getTarget());
         //
         final LoggerConfig loggerConfig = configuration.getLoggerConfig("com.example.foo");
@@ -51,6 +50,22 @@ public class Log4j1ConfigurationFactoryTest {
         return appender.getLayout();
     }
 
+    private Layout<?> testFile(final String configResource) throws Exception {
+        final URL configLocation = ClassLoader.getSystemResource(configResource);
+        assertNotNull(configLocation);
+        final Configuration configuration = new Log4j1ConfigurationFactory().getConfiguration("test",
+                configLocation.toURI());
+        assertNotNull(configuration);
+        final FileAppender appender = configuration.getAppender("File");
+        assertNotNull(appender);
+        assertEquals("target/mylog.txt", appender.getFileName());
+        //
+        final LoggerConfig loggerConfig = configuration.getLoggerConfig("com.example.foo");
+        assertNotNull(loggerConfig);
+        assertEquals(Level.DEBUG, loggerConfig.getLevel());
+        return appender.getLayout();
+    }
+
     @Test
     public void testConsoleEnhancedPatternLayout() throws Exception {
         final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-EnhancedPatternLayout.properties");
@@ -88,4 +103,10 @@ public class Log4j1ConfigurationFactoryTest {
         assertTrue(layout.isLocationInfo());
         assertFalse(layout.isProperties());
     }
+
+    @Test
+    public void testFileSimpleLayout() throws Exception {
+        final PatternLayout layout = (PatternLayout) testFile("config-1.2/log4j-file-SimpleLayout.properties");
+        assertEquals("%level - %m%n", layout.getConversionPattern());
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/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 01a4463..6793eb2 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
@@ -11,7 +11,6 @@ log4j.rootLogger=TRACE, Console
 #
 
 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 %X %x: %m%n

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties
index 304180c..216a12e 100644
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties
@@ -11,7 +11,6 @@ log4j.rootLogger=TRACE, Console
 #
 
 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.HTMLLayout
 log4j.appender.Console.layout.Title=Headline

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties
index fab7070..810a494 100644
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties
@@ -11,7 +11,6 @@ log4j.rootLogger=TRACE, Console
 #
 
 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.PatternLayout
 log4j.appender.Console.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p: %m%n

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties
index 5e915f8..5a8ac4e 100644
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties
@@ -11,7 +11,6 @@ log4j.rootLogger=TRACE, Console
 #
 
 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.SimpleLayout
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
index 9f91789..80d38c2 100644
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
@@ -11,7 +11,6 @@ log4j.rootLogger=TRACE, Console
 #
 
 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.TTCCLayout
 log4j.appender.Console.layout.ThreadPrinting=true

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties
index 96302a2..c8190ec 100644
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties
@@ -11,7 +11,6 @@ log4j.rootLogger=TRACE, Console
 #
 
 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.xml.XMLLayout
 log4j.appender.Console.layout.LocationInfo=true

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3aceb2a3/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.properties
new file mode 100644
index 0000000..4d3ec0d
--- /dev/null
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.properties
@@ -0,0 +1,17 @@
+###############################################################################
+#
+# Log4J 1.2 Configuration.
+#
+
+log4j.rootLogger=TRACE, File
+
+##############################################################################
+#
+# The Console log
+#
+
+log4j.appender.File=org.apache.log4j.FileAppender
+log4j.appender.File.File=target/mylog.txt
+log4j.appender.File.layout=org.apache.log4j.SimpleLayout
+
+log4j.logger.com.example.foo = DEBUG


[34/42] logging-log4j2 git commit: [LOG4J2-1551] Update JMS test from ActiveMQ 5.13.4 to 5.14.0. Local build OK.

Posted by rp...@apache.org.
[LOG4J2-1551] Update JMS test from ActiveMQ 5.13.4 to 5.14.0. Local
build OK.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: d8d2ac0854a08ec7286c3597bc0dcb033642f33c
Parents: 3e55d68
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 15:14:59 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 15:14:59 2016 -0700

----------------------------------------------------------------------
 pom.xml                 | 2 +-
 src/changes/changes.xml | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d8d2ac08/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 91c5357..eb87b95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -221,7 +221,7 @@
     <projectDir />
     <commonsLoggingVersion>1.2</commonsLoggingVersion>
     <osgi.api.version>4.3.1</osgi.api.version>
-    <activemq.version>5.13.4</activemq.version>
+    <activemq.version>5.14.0</activemq.version>
     <!-- Allow Clirr severity to be overriden by the command-line option -DminSeverity=level -->
     <minSeverity>info</minSeverity>
   </properties>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d8d2ac08/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 05aa5f7..0afb959 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -153,6 +153,9 @@
       <action issue="LOG4J2-1487" dev="ggregory" type="update" due-to="Gary Gregory">
         Update JMS test from ActiveMQ 5.13.3 to 5.13.4.
       </action>
+      <action issue="LOG4J2-1551" dev="ggregory" type="update" due-to="Gary Gregory">
+        Update JMS test from ActiveMQ 5.13.4 to 5.14.0.
+      </action>
       <action issue="LOG4J2-1543" dev="ggregory" type="update" due-to="Gary Gregory">
         Remove deprecated Core API org.apache.logging.log4j.core.util.Constants.UTF_8.
       </action>


[27/42] logging-log4j2 git commit: [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext and add Configuration.getLoggerContext(). Note Core method signature change.

Posted by rp...@apache.org.
[LOG4J2-1547] The Core AbstractConfiguration should track its
LoggerContext and add Configuration.getLoggerContext(). Note Core method
signature change.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 213a24768263f513439ee6e0d9de326ed6f59218
Parents: e8b97fd
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 08:38:38 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 08:38:38 2016 -0700

----------------------------------------------------------------------
 src/site/xdoc/manual/customconfig.xml | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/213a2476/src/site/xdoc/manual/customconfig.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/customconfig.xml b/src/site/xdoc/manual/customconfig.xml
index ed84279..ced5cbc 100644
--- a/src/site/xdoc/manual/customconfig.xml
+++ b/src/site/xdoc/manual/customconfig.xml
@@ -128,12 +128,12 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(ConfigurationSource source) {
-        return getConfiguration(source.toString(), null);
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
+        return getConfiguration(loggerContext, source.toString(), null);
     }
 
     @Override
-    public Configuration getConfiguration(final String name, final URI configLocation) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
         ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder();
         return createConfiguration(name, builder);
     }
@@ -143,6 +143,10 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
         return new String[] {"*"};
     }
 }]]></pre>
+            <p>
+              As of version 2.7, the <code>ConfigurationFactory.getConfiguration()</code> methods take an 
+              additional <code>LoggerContext</code> parameter.
+            </p>
           </subsection>
         <a name="Configurator"/>
           <subsection name="Reconfigure Log4j Using ConfigurationBuilder with the Configurator">


[07/42] logging-log4j2 git commit: [LOG4J2-1548][CronTriggeringPolicy] ConfigurationScheduler schedules the task infinitely after first fire. Heads-up: The new test has a TODO noting that the test uses Thread.sleep() all over the place; it takes about a

Posted by rp...@apache.org.
[LOG4J2-1548][CronTriggeringPolicy] ConfigurationScheduler schedules the
task infinitely after first fire. Heads-up: The new test has a TODO
noting that the test uses Thread.sleep() all over the place; it takes
about a minute to run. Expect a 1-minute slower build until a better
test is in place. Note that the part of the patch related to
ResolverUtil was not applied.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 33aaf3d52503a3c5781a30424994ad1b5907d59e
Parents: 8b40c1f
Author: Gary Gregory <gg...@apache.org>
Authored: Wed Aug 24 08:51:39 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Wed Aug 24 08:51:39 2016 -0700

----------------------------------------------------------------------
 .../core/config/ConfigurationScheduler.java     |   2 +-
 .../RollingAppenderCronOnceADayTest.java        | 128 +++++++++++++++++++
 .../resources/log4j-rolling-cron-once-a-day.xml |  47 +++++++
 .../src/test/resources/log4j-rolling-cron.xml   |   2 +-
 .../src/test/resources/log4j-rolling-cron2.xml  |   2 +-
 src/changes/changes.xml                         |   3 +
 6 files changed, 181 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/33aaf3d5/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 744ed24..e6291f9 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
@@ -182,7 +182,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
             } catch(final Throwable ex) {
                 LOGGER.error("Error running command", ex);
             } finally {
-                Date fireDate = cronExpression.getNextInvalidTimeAfter(new Date());
+                Date fireDate = cronExpression.getNextValidTimeAfter(new Date());
                 final ScheduledFuture<?> future = schedule(this, nextFireInterval(fireDate), TimeUnit.MILLISECONDS);
                 scheduledFuture.reset(future, fireDate);
             }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/33aaf3d5/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
new file mode 100644
index 0000000..2e091c4
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.rolling;
+
+import static org.apache.logging.log4j.hamcrest.Descriptors.that;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.Matchers.endsWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Calendar;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.appender.RollingFileAppender;
+import org.apache.logging.log4j.core.util.CronExpression;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.hamcrest.Matcher;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+
+/**
+ * This test currently takes about a minute to run.
+ */
+public class RollingAppenderCronOnceADayTest {
+
+    private static final String UTF_8 = "UTF-8";
+    private static final String CONFIG = "log4j-rolling-cron-once-a-day.xml";
+    private static final String CONFIG_TARGET = "log4j-rolling-cron-once-a-day-target.xml";
+    private static final String TARGET = "target";
+    private static final String DIR = TARGET + "/rolling-cron-once-a-day";
+    private static final String FILE = DIR + "/rollingtest.log";
+    private static final String TARGET_TEST_CLASSES = TARGET + "/test-classes";
+
+    private static String cronExpression;
+    private static long remainingTime;
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+      final Path src = FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG);
+      String content = new String(Files.readAllBytes(src), UTF_8);
+      Calendar cal = Calendar.getInstance();
+      cal.add(Calendar.SECOND, 45);
+      remainingTime = cal.getTimeInMillis() - System.currentTimeMillis();
+      cronExpression =  String.format("%d %d %d * * ?",
+          cal.get(Calendar.SECOND),
+          cal.get(Calendar.MINUTE),
+          cal.get(Calendar.HOUR_OF_DAY));
+      content = content.replace("@CRON_EXPR@", cronExpression);
+      Files.write(FileSystems.getDefault()
+            .getPath(TARGET_TEST_CLASSES, CONFIG_TARGET), content.getBytes(UTF_8));
+      StatusLogger.getLogger().debug("Cron expression will be " + cronExpression + " in " + remainingTime + "ms");
+    }
+
+    private final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG_TARGET);
+
+    @Rule
+    public RuleChain chain = loggerContextRule.withCleanFoldersRule(true, false, 1, DIR);
+
+    @Test
+    public void testAppender() throws Exception {
+        // TODO Is there a better way to test than putting the thread to sleep all over the place?
+        final Logger logger = loggerContextRule.getLogger();
+        File file = new File(FILE);
+        assertTrue("Log file does not exist", file.exists());
+        logger.debug("This is test message number 1, waiting for rolling");
+
+        final RollingFileAppender app = (RollingFileAppender) loggerContextRule.getContext().getConfiguration().getAppender("RollingFile");
+        final TriggeringPolicy policy = app.getManager().getTriggeringPolicy();
+        assertNotNull("No triggering policy", policy);
+        assertTrue("Incorrect policy type", policy instanceof CronTriggeringPolicy);
+        final CronExpression expression = ((CronTriggeringPolicy) policy).getCronExpression();
+        assertEquals("Incorrect cron expresion", cronExpression, expression.getCronExpression());
+        logger.debug("Cron expression will be {}", expression.getCronExpression());
+
+        // force a reconfiguration
+        for (int i = 1; i <= 20; ++i) {
+            logger.debug("Adding first event {}", i);
+        }
+
+        Thread.sleep(remainingTime);
+        final File dir = new File(DIR);
+        assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
+
+        for (int i = 1; i < 20; i++) {
+          logger.debug("Adding again event {}", i);
+        }
+        Thread.sleep(1000);
+        for (int i = 1; i < 10; i++) {
+          logger.debug("Adding some more event {}", i);
+          Thread.sleep(1000);
+        }
+        final Matcher<File> hasGzippedFile = hasName(that(endsWith(".gz")));
+        int count = 0;
+        final File[] files = dir.listFiles();
+        for (File generatedFile : files) {
+          if (hasGzippedFile.matches(generatedFile)) {
+              count++;
+          }
+        }
+
+        assertNotEquals("No compressed files found", 0, count);
+        assertEquals("Multiple files found" , 1, count);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/33aaf3d5/log4j-core/src/test/resources/log4j-rolling-cron-once-a-day.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j-rolling-cron-once-a-day.xml b/log4j-core/src/test/resources/log4j-rolling-cron-once-a-day.xml
new file mode 100644
index 0000000..9d71fc9
--- /dev/null
+++ b/log4j-core/src/test/resources/log4j-rolling-cron-once-a-day.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+<Configuration status="ERROR" name="RollingCronTestOnceADay">
+  <Properties>
+    <Property name="filename">target/rolling-cron-once-a-day/rollingtest.log</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="STDOUT" target="SYSTEM_OUT">
+      <PatternLayout pattern="%p %C{1.} [%t] %m%n"/>
+    </Console>
+    <RollingFile name="RollingFile"
+    	 fileName="${filename}"
+    	 filePattern="target/rolling-cron-once-a-day/rollingtest-%d{yyyyMMdd}_%d{HHmmss}-%i.log.gz"
+    	 immediateFlush="true">
+      <PatternLayout pattern="%d %p %C{1.} [%t] %m%n" />
+      <CronTriggeringPolicy schedule="@CRON_EXPR@"/>
+    </RollingFile>
+  </Appenders>
+
+  <Loggers>
+    <Logger name="org.apache.logging.log4j.core.appender.rolling" level="DEBUG" additivity="false">
+      <AppenderRef ref="RollingFile"/>
+    </Logger>
+
+    <Root level="ERROR">
+      <AppenderRef ref="STDOUT"/>
+    </Root>
+  </Loggers>
+
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/33aaf3d5/log4j-core/src/test/resources/log4j-rolling-cron.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j-rolling-cron.xml b/log4j-core/src/test/resources/log4j-rolling-cron.xml
index 9579804..be6fa70 100644
--- a/log4j-core/src/test/resources/log4j-rolling-cron.xml
+++ b/log4j-core/src/test/resources/log4j-rolling-cron.xml
@@ -44,7 +44,7 @@
   <Loggers>
     <Logger name="org.apache.logging.log4j.core.appender.rolling" level="debug" additivity="false">
       <AppenderRef ref="RollingFile"/>
-    </Logger>>
+    </Logger>
 
     <Root level="error">
       <AppenderRef ref="STDOUT"/>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/33aaf3d5/log4j-core/src/test/resources/log4j-rolling-cron2.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j-rolling-cron2.xml b/log4j-core/src/test/resources/log4j-rolling-cron2.xml
index a6a17ed..9110f50 100644
--- a/log4j-core/src/test/resources/log4j-rolling-cron2.xml
+++ b/log4j-core/src/test/resources/log4j-rolling-cron2.xml
@@ -44,7 +44,7 @@
   <Loggers>
     <Logger name="org.apache.logging.log4j.core.appender.rolling" level="debug" additivity="false">
       <AppenderRef ref="RollingFile"/>
-    </Logger>>
+    </Logger>
 
     <Root level="error">
       <AppenderRef ref="STDOUT"/>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/33aaf3d5/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 776da03..dbc3310 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
   </properties>
   <body>
     <release version="2.7" date="2016-MM-DD" description="GA Release 2.7">
+      <action issue="LOG4J2-1548" dev="ggregory" type="fix" due-to="Gary Gregory">
+        [CronTriggeringPolicy] ConfigurationScheduler schedules the task infinitely after first fire.
+      </action>
       <action issue="LOG4J2-1506" dev="ggregory" type="fix" due-to="Johannes Schleger">
         Unregister JMX ignores log4j2.disable.jmx property.
       </action>


[30/42] logging-log4j2 git commit: Merge remote-tracking branch 'origin/master' into LOG4J2-1539

Posted by rp...@apache.org.
Merge remote-tracking branch 'origin/master' into LOG4J2-1539

Conflicts:
	log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java


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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 01f59e4640b78f251813d712cc011686907de557
Parents: a4ef9a1 2cfc94b
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 10:05:21 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 10:05:21 2016 -0700

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      |  2 +-
 .../apache/log4j/BasicConfigurationFactory.java |  4 +-
 .../log4j/core/appender/AbstractManager.java    | 15 ++++--
 .../core/appender/ConfigurationFactoryData.java | 50 ++++++++++++++++++++
 .../log4j/core/appender/ConsoleAppender.java    |  4 --
 .../log4j/core/appender/FileAppender.java       | 12 ++---
 .../log4j/core/appender/FileManager.java        | 30 +++++++-----
 .../core/appender/OutputStreamManager.java      | 12 ++---
 .../core/appender/RandomAccessFileAppender.java |  2 +-
 .../core/appender/RandomAccessFileManager.java  | 27 ++++++-----
 .../core/appender/RollingFileAppender.java      | 16 +++----
 .../RollingRandomAccessFileAppender.java        |  2 +-
 .../log4j/core/appender/WriterManager.java      |  2 +-
 .../appender/db/AbstractDatabaseManager.java    |  2 +-
 .../log4j/core/appender/mom/JmsManager.java     |  2 +-
 .../core/appender/mom/jeromq/JeroMqManager.java |  2 +-
 .../core/appender/mom/kafka/KafkaManager.java   |  2 +-
 .../appender/rolling/RollingFileManager.java    | 32 +++++++------
 .../rolling/RollingRandomAccessFileManager.java | 32 ++++++++-----
 .../log4j/core/config/ConfigurationFactory.java |  4 +-
 .../composite/CompositeConfiguration.java       |  2 +-
 .../config/xml/XmlConfigurationFactory.java     |  1 +
 .../config/yaml/YamlConfigurationFactory.java   |  2 +-
 .../logging/log4j/core/net/JndiManager.java     |  2 +-
 .../logging/log4j/core/net/SmtpManager.java     |  2 +-
 .../log4j/core/BasicConfigurationFactory.java   |  4 +-
 .../appender/RandomAccessFileManagerTest.java   | 18 +++----
 .../rolling/OnStartupTriggeringPolicyTest.java  |  2 +-
 .../RollingRandomAccessFileManagerTest.java     | 24 +++++-----
 .../builder/CustomConfigurationFactory.java     |  6 +--
 .../flume/appender/AbstractFlumeManager.java    |  2 +-
 .../CustomConfigurationFactory.java             |  4 +-
 src/changes/changes.xml                         |  3 ++
 src/site/xdoc/manual/customconfig.xml           | 10 ++--
 src/site/xdoc/manual/extending.xml              |  8 ++--
 35 files changed, 214 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/01f59e46/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/01f59e46/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
----------------------------------------------------------------------
diff --cc log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
index 3fcf864,b741b4e..3f8ba2a
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
@@@ -33,7 -33,9 +34,8 @@@ import org.apache.logging.log4j.core.ap
  import org.apache.logging.log4j.core.appender.ManagerFactory;
  import org.apache.logging.log4j.core.appender.rolling.action.AbstractAction;
  import org.apache.logging.log4j.core.appender.rolling.action.Action;
+ import org.apache.logging.log4j.core.config.Configuration;
  import org.apache.logging.log4j.core.util.Constants;
 -import org.apache.logging.log4j.core.util.Log4jThread;
  
  /**
   * The Rolling File Manager.


[40/42] logging-log4j2 git commit: LOG4J2-1010 DynamicThresholdFilter should get context data from the configured ContextDataInjector, not hard-coded from ThreadContext

Posted by rp...@apache.org.
LOG4J2-1010 DynamicThresholdFilter should get context data from the configured ContextDataInjector, not hard-coded from ThreadContext


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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 498bdb579a42c52542caf650bb4929dbf80ac8cc
Parents: 3ebff53 0c9c9f3
Author: rpopma <rp...@apache.org>
Authored: Sat Aug 27 15:51:09 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Aug 27 15:51:09 2016 +0900

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      |    9 +-
 .../log4j/config/Log4j1ConfigurationParser.java |  210 ++--
 .../apache/log4j/BasicConfigurationFactory.java |   13 +-
 .../config/Log4j1ConfigurationFactoryTest.java  |   29 +-
 ...g4j-console-EnhancedPatternLayout.properties |    1 -
 .../log4j-console-HtmlLayout.properties         |    1 -
 .../log4j-console-PatternLayout.properties      |    1 -
 .../log4j-console-SimpleLayout.properties       |    1 -
 .../log4j-console-TTCCLayout.properties         |    1 -
 .../log4j-console-XmlLayout.properties          |    1 -
 .../log4j-file-SimpleLayout.properties          |   17 +
 .../logging/log4j/core/AbstractLifeCycle.java   |    8 +
 .../apache/logging/log4j/core/LifeCycle.java    |   13 +
 .../logging/log4j/core/LoggerContext.java       |  113 +-
 .../log4j/core/appender/AbstractManager.java    |   17 +-
 .../core/appender/ConfigurationFactoryData.java |   50 +
 .../log4j/core/appender/ConsoleAppender.java    |    4 -
 .../log4j/core/appender/FileAppender.java       |   12 +-
 .../log4j/core/appender/FileManager.java        |   30 +-
 .../core/appender/OutputStreamManager.java      |   12 +-
 .../core/appender/RandomAccessFileAppender.java |    2 +-
 .../core/appender/RandomAccessFileManager.java  |   27 +-
 .../core/appender/RollingFileAppender.java      |   16 +-
 .../RollingRandomAccessFileAppender.java        |    2 +-
 .../log4j/core/appender/WriterManager.java      |    2 +-
 .../appender/db/AbstractDatabaseManager.java    |    2 +-
 .../log4j/core/appender/mom/JmsManager.java     |    2 +-
 .../core/appender/mom/jeromq/JeroMqManager.java |    2 +-
 .../core/appender/mom/kafka/KafkaAppender.java  |    7 +-
 .../core/appender/mom/kafka/KafkaManager.java   |   22 +-
 .../appender/rolling/RollingFileManager.java    |   44 +-
 .../rolling/RollingRandomAccessFileManager.java |   32 +-
 .../core/config/AbstractConfiguration.java      |   15 +-
 .../log4j/core/config/Configuration.java        |    8 +
 .../log4j/core/config/ConfigurationFactory.java | 1113 +++++++++---------
 .../core/config/ConfigurationScheduler.java     |   10 +-
 .../core/config/ConfiguratonFileWatcher.java    |   10 +-
 .../logging/log4j/core/config/Configurator.java |   36 +-
 .../log4j/core/config/DefaultConfiguration.java |    2 +-
 .../log4j/core/config/NullConfiguration.java    |    2 +-
 .../builder/api/ConfigurationBuilder.java       |    8 +
 .../config/builder/impl/BuiltConfiguration.java |    5 +-
 .../impl/DefaultConfigurationBuilder.java       |   29 +-
 .../composite/CompositeConfiguration.java       |    4 +-
 .../core/config/json/JsonConfiguration.java     |   14 +-
 .../config/json/JsonConfigurationFactory.java   |    5 +-
 .../core/config/plugins/util/ResolverUtil.java  |   11 +-
 .../properties/PropertiesConfiguration.java     |    8 +-
 .../PropertiesConfigurationBuilder.java         |   16 +-
 .../PropertiesConfigurationFactory.java         |   10 +-
 .../log4j/core/config/xml/XmlConfiguration.java |    7 +-
 .../config/xml/XmlConfigurationFactory.java     |    6 +-
 .../core/config/yaml/YamlConfiguration.java     |    7 +-
 .../config/yaml/YamlConfigurationFactory.java   |    5 +-
 .../core/filter/DynamicThresholdFilter.java     |   84 +-
 .../log4j/core/impl/Log4jContextFactory.java    |    6 +-
 .../log4j/core/jmx/LoggerContextAdmin.java      |    4 +-
 .../apache/logging/log4j/core/jmx/Server.java   |    6 +-
 .../logging/log4j/core/net/JndiManager.java     |    2 +-
 .../logging/log4j/core/net/SmtpManager.java     |    2 +-
 .../core/net/server/AbstractSocketServer.java   |    7 +-
 .../log4j/core/net/server/JmsServer.java        |    7 +
 .../util/DefaultShutdownCallbackRegistry.java   |    7 +
 .../log4j/core/util/Log4jThreadFactory.java     |   11 +
 .../log4j/core/BasicConfigurationFactory.java   |    6 +-
 .../appender/RandomAccessFileManagerTest.java   |   18 +-
 .../rolling/OnStartupTriggeringPolicyTest.java  |    2 +-
 .../RandomRollingAppenderOnStartupTest.java     |    2 +-
 .../RollingAppenderCronOnceADayTest.java        |  125 ++
 .../rolling/RollingAppenderCronTest.java        |    2 +-
 .../RollingAppenderCustomDeleteActionTest.java  |    2 +-
 ...lingAppenderDeleteAccumulatedCount1Test.java |    2 +-
 ...lingAppenderDeleteAccumulatedCount2Test.java |    2 +-
 ...ollingAppenderDeleteAccumulatedSizeTest.java |    2 +-
 .../RollingAppenderDeleteMaxDepthTest.java      |    2 +-
 .../RollingAppenderDeleteNestedTest.java        |    2 +-
 .../RollingAppenderDeleteScriptFri13thTest.java |    2 +-
 .../RollingAppenderDeleteScriptTest.java        |    2 +-
 ...ollingAppenderNoUnconditionalDeleteTest.java |    2 +-
 .../rolling/RollingAppenderOnStartupTest.java   |    2 +-
 .../rolling/RollingAppenderSizeTest.java        |    2 +-
 .../rolling/RollingAppenderTimeAndSizeTest.java |    4 +-
 .../rolling/RollingAppenderTimeTest.java        |    2 +-
 ...RandomAccessFileManagerHeaderFooterTest.java |    3 +-
 .../RollingRandomAccessFileManagerTest.java     |   24 +-
 .../log4j/core/config/ConfigurationTest.java    |    6 +
 .../builder/CustomConfigurationFactory.java     |   11 +-
 .../plugins/util/PluginManagerPackagesTest.java |    2 +-
 .../util/ResolverUtilCustomProtocolTest.java    |  208 ++++
 .../config/plugins/util/ResolverUtilTest.java   |  146 ++-
 .../core/filter/DynamicThresholdFilterTest.java |   17 +
 .../core/layout/CsvParameterLayoutTest.java     |   59 +-
 .../logging/log4j/junit/LoggerContextRule.java  |   25 +-
 .../junit/URLStreamHandlerFactoryRule.java      |   96 ++
 .../resources/log4j-rolling-cron-once-a-day.xml |   47 +
 .../src/test/resources/log4j-rolling-cron.xml   |    2 +-
 .../src/test/resources/log4j-rolling-cron2.xml  |    2 +-
 .../flume/appender/AbstractFlumeManager.java    |    2 +-
 .../configuration/CustomConfiguration.java      |   13 +-
 .../CustomConfigurationFactory.java             |   12 +-
 pom.xml                                         |    2 +-
 src/changes/changes.xml                         |   62 +-
 src/site/xdoc/manual/customconfig.xml           |   10 +-
 src/site/xdoc/manual/extending.xml              |    8 +-
 104 files changed, 2099 insertions(+), 1011 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/498bdb57/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
----------------------------------------------------------------------
diff --cc log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
index 3c6cdaa,24cfada..eaa999c
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
@@@ -40,9 -35,7 +40,9 @@@ import org.apache.logging.log4j.core.ut
  import org.apache.logging.log4j.message.Message;
  
  /**
-  * Compare against a log level that is associated with a context value. By default the context is the
 - * Compares against a log level that is associated with an MDC value.
++ * Compares against a log level that is associated with a context value. By default the context is the
 + * {@link ThreadContext}, but users may {@linkplain ContextDataInjectorFactory configure} a custom
 + * {@link ContextDataInjector} which obtains context data from some other source.
   */
  @Plugin(name = "DynamicThresholdFilter", category = Node.CATEGORY, elementType = Filter.ELEMENT_TYPE, printObject = true)
  public final class DynamicThresholdFilter extends AbstractFilter {
@@@ -70,9 -63,9 +70,10 @@@
          final Level level = defaultThreshold == null ? Level.ERROR : defaultThreshold;
          return new DynamicThresholdFilter(key, map, level, onMatch, onMismatch);
      }
 -    
++
      private Level defaultThreshold = Level.ERROR;
      private final String key;
 +    private final ContextDataInjector injector = ContextDataInjectorFactory.createInjector();
      private Map<String, Level> levelMap = new HashMap<>();
  
      private DynamicThresholdFilter(final String key, final Map<String, Level> pairs, final Level defaultLevel,
@@@ -153,18 -146,88 +154,97 @@@
      @Override
      public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
                           final Object... params) {
 -        return filter(level, ThreadContext.getContext());
 +        return filter(level, currentContextData());
 +    }
 +
 +    private ContextData currentContextData() {
 +        return injector.injectContextData(null, reusableInstance());
 +    }
 +
 +    private MutableContextData reusableInstance() {
 +        // TODO if (Constants.ENABLE_THREADLOCALS) return thread-local instance
 +        return ContextDataFactory.createContextData(); // creates temporary object
      }
  
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2, final Object p3) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2, final Object p3,
+             final Object p4) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2, final Object p3,
+             final Object p4, final Object p5) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2, final Object p3,
+             final Object p4, final Object p5, final Object p6) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2, final Object p3,
+             final Object p4, final Object p5, final Object p6,
+             final Object p7) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2, final Object p3,
+             final Object p4, final Object p5, final Object p6,
+             final Object p7, final Object p8) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
+ 
+     @Override
+     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
+             final Object p0, final Object p1, final Object p2, final Object p3,
+             final Object p4, final Object p5, final Object p6,
+             final Object p7, final Object p8, final Object p9) {
+         return filter(level, ThreadContext.getContext());
+ 
+     }
 -    
++
      public String getKey() {
          return this.key;
      }


[09/42] logging-log4j2 git commit: [LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not supported. Another go around with a better set of tests from Pierrick HYMBERT.

Posted by rp...@apache.org.
[LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not
supported. Another go around with a better set of tests from Pierrick
HYMBERT.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 2d5812b2e98c2e1ca8e7acf322ae34aba34429c7
Parents: 33aaf3d
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 13:03:58 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 13:03:58 2016 -0700

----------------------------------------------------------------------
 .../core/config/plugins/util/ResolverUtil.java  |  11 +-
 .../plugins/util/PluginManagerPackagesTest.java |   2 +-
 .../util/ResolverUtilCustomProtocolTest.java    | 227 +++++++++++++++++++
 .../config/plugins/util/ResolverUtilTest.java   | 146 +++++++-----
 4 files changed, 322 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2d5812b2/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
index 14bf1e8..a353228 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
@@ -199,9 +199,14 @@ public class ResolverUtil {
                         close(stream, newURL);
                     }
                 } else if (VFS.equals(url.getProtocol())) {
-                    final String path = urlPath.substring(1, urlPath.length() - packageName.length() - 2);
-                    final File file = new File(path);
-                    loadImplementationsInJar(test, packageName, file);
+                    final String containerPath = urlPath.substring(1,
+                                                  urlPath.length() - packageName.length() - 2);
+                    final File containerFile = new File(containerPath);
+                    if (containerFile.isDirectory()) {
+                        loadImplementationsInDirectory(test, packageName, new File(containerFile, packageName));
+                    } else {
+                        loadImplementationsInJar(test, packageName, containerFile);
+                    }
                 } else if (BUNDLE_RESOURCE.equals(url.getProtocol())) {
                     loadImplementationsInBundle(test, packageName);
                 } else {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2d5812b2/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/PluginManagerPackagesTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/PluginManagerPackagesTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/PluginManagerPackagesTest.java
index 5808b10..c97643f 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/PluginManagerPackagesTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/PluginManagerPackagesTest.java
@@ -85,7 +85,7 @@ public class PluginManagerPackagesTest {
         assertEquals("abc123XYZ", messages.get(0));
     }
 
-    private void compile(final File f) throws IOException {
+    static void compile(final File f) throws IOException {
         // set up compiler
         final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
         final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2d5812b2/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
new file mode 100644
index 0000000..86bc000
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
@@ -0,0 +1,227 @@
+/*
+ * 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.config.plugins.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.apache.logging.log4j.core.config.plugins.util.ResolverUtilTest.compileAndCreateClassLoader;
+import static org.apache.logging.log4j.core.config.plugins.util.ResolverUtilTest.compileJarAndCreateClassLoader;
+
+import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.PluginTest;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+/**
+ * Tests the ResolverUtil class for custom protocol like bundleresource, vfs, vfszip.
+ */
+public class ResolverUtilCustomProtocolTest {
+
+    static class NoopURLStreamHandlerFactory implements URLStreamHandlerFactory {
+        @Override
+        public URLStreamHandler createURLStreamHandler(String protocol) {
+            return new URLStreamHandler() {
+                @Override
+                protected URLConnection openConnection(URL url) {
+                    return open(url, null);
+                }
+
+                private URLConnection open(URL url, Proxy proxy) {
+                    return new URLConnection(url) {
+                        @Override
+                        public void connect() throws IOException {
+                            // do nothing
+                        }
+                    };
+                }
+
+                @Override
+                protected URLConnection openConnection(URL url, Proxy proxy) {
+                    return open(url, proxy);
+                }
+
+                @Override
+                protected int getDefaultPort() {
+                    return 1;
+                }
+            };
+        }
+    }
+
+    static class SingleURLClassLoader extends ClassLoader {
+        private URL url;
+
+        public SingleURLClassLoader(URL url) {
+            this.url = url;
+        }
+
+        public SingleURLClassLoader(URL url, ClassLoader parent) {
+            super(parent);
+            this.url = url;
+        }
+
+        @Override
+        protected URL findResource(String name) {
+            return url;
+        }
+
+        @Override
+        public URL getResource(String name) {
+            return findResource(name);
+        }
+
+        @Override
+        public Enumeration<URL> getResources(String name) throws IOException {
+            return findResources(name);
+        }
+
+        @Override
+        protected Enumeration<URL> findResources(String name) throws IOException {
+            return Collections.enumeration(Arrays.asList(findResource(name)));
+        }
+    }
+
+    @BeforeClass
+    public static void defineURLHandler() {
+        URL.setURLStreamHandlerFactory(new NoopURLStreamHandlerFactory());
+    }
+
+    @AfterClass
+    public static void removeURLHandler() throws Exception {
+        // Simulate this - Not the best way, but no other choice welcome ?
+        // URL.setURLStreamHandlerFactory(null);
+        Field handlersFields = URL.class.getDeclaredField("handlers");
+        if (!handlersFields.isAccessible()) {
+            handlersFields.setAccessible(true);
+        }
+        Field factoryFields = URL.class.getDeclaredField("factory");
+        if (!factoryFields.isAccessible()) {
+            factoryFields.setAccessible(true);
+        }
+
+        @SuppressWarnings("unchecked")
+        Hashtable<String, URLStreamHandler> handlers = (Hashtable<String, URLStreamHandler>) handlersFields.get(null);
+        handlers.clear();
+        factoryFields.set(null, null);
+    }
+
+    @Test
+    public void testExtractPathFromVfsEarJarWindowsUrl() throws Exception {
+        final URL url = new URL(
+                "vfs:/C:/jboss/jboss-eap-6.4/standalone/deployments/com.xxx.yyy.application-ear.ear/lib/com.xxx.yyy.logging.jar/com/xxx/yyy/logging/config/");
+        final String expected = "/C:/jboss/jboss-eap-6.4/standalone/deployments/com.xxx.yyy.application-ear.ear/lib/com.xxx.yyy.logging.jar/com/xxx/yyy/logging/config/";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromVfsWarClassesWindowsUrl() throws Exception {
+        final URL url = new URL(
+                "vfs:/C:/jboss/jboss-eap-6.4/standalone/deployments/test-log4j2-web-standalone.war/WEB-INF/classes/org/hypik/test/jboss/eap7/logging/config/");
+        final String expected = "/C:/jboss/jboss-eap-6.4/standalone/deployments/test-log4j2-web-standalone.war/WEB-INF/classes/org/hypik/test/jboss/eap7/logging/config/";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromVfsWarClassesLinuxUrl() throws Exception {
+        final URL url = new URL(
+                "vfs:/content/mycustomweb.war/WEB-INF/classes/org/hypik/test/jboss/log4j2/logging/pluginweb/");
+        final String expected = "/content/mycustomweb.war/WEB-INF/classes/org/hypik/test/jboss/log4j2/logging/pluginweb/";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromVfszipUrl() throws Exception {
+        final URL url = new URL(
+                "vfszip:/home2/jboss-5.0.1.CR2/jboss-as/server/ais/ais-deploy/myear.ear/mywar.war/WEB-INF/some.xsd");
+        final String expected = "/home2/jboss-5.0.1.CR2/jboss-as/server/ais/ais-deploy/myear.ear/mywar.war/WEB-INF/some.xsd";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromVfsEarJarLinuxUrl() throws Exception {
+        final URL url = new URL(
+                "vfs:/content/test-log4k2-ear.ear/lib/test-log4j2-jar-plugins.jar/org/hypik/test/jboss/log4j2/pluginjar/");
+        final String expected = "/content/test-log4k2-ear.ear/lib/test-log4j2-jar-plugins.jar/org/hypik/test/jboss/log4j2/pluginjar/";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromVfszipUrlWithPlusCharacters() throws Exception {
+        final URL url = new URL("vfszip:/path+with+plus/file+name+with+plus.xml");
+        final String expected = "/path+with+plus/file+name+with+plus.xml";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromVfsUrlWithPlusCharacters() throws Exception {
+        final URL url = new URL("vfs:/path+with+plus/file+name+with+plus.xml");
+        final String expected = "/path+with+plus/file+name+with+plus.xml";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromResourceBundleUrl() throws Exception {
+        final URL url = new URL("bundleresource:/some/path/some/file.properties");
+        final String expected = "/some/path/some/file.properties";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testExtractPathFromResourceBundleUrlWithPlusCharacters() throws Exception {
+        final URL url = new URL("bundleresource:/some+path/some+file.properties");
+        final String expected = "/some+path/some+file.properties";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Test
+    public void testFindInPackageFromVfsDirectoryURL() throws Exception {
+        ClassLoader cl = compileAndCreateClassLoader("3");
+
+        ResolverUtil resolverUtil = new ResolverUtil();
+        resolverUtil.setClassLoader(new SingleURLClassLoader(new URL("vfs:/target/resolverutil3/customplugin3/"), cl));
+        resolverUtil.findInPackage(new PluginTest(), "customplugin3");
+        assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+        assertEquals("Unexpected class resolved", cl.loadClass("customplugin3.FixedString3Layout"),
+                resolverUtil.getClasses().iterator().next());
+    }
+
+    @Test
+    public void testFindInPackageFromVfsJarURL() throws Exception {
+        ClassLoader cl = compileJarAndCreateClassLoader("4");
+
+        ResolverUtil resolverUtil = new ResolverUtil();
+        resolverUtil.setClassLoader(
+                new SingleURLClassLoader(new URL("vfs:/target/resolverutil4/customplugin4.jar/customplugin4/"), cl));
+        resolverUtil.findInPackage(new PluginTest(), "customplugin4");
+        assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+        assertEquals("Unexpected class resolved", cl.loadClass("customplugin4.FixedString4Layout"),
+                resolverUtil.getClasses().iterator().next());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2d5812b2/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index cbcd23c..76ab740 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -20,12 +20,23 @@ package org.apache.logging.log4j.core.config.plugins.util;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-
-import org.junit.Ignore;
+import java.net.URLClassLoader;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.PluginTest;
 import org.junit.Test;
 
 /**
@@ -93,64 +104,6 @@ public class ResolverUtilTest {
         assertEquals(expected, new ResolverUtil().extractPath(url));
     }
 
-    @Ignore
-    @Test
-    public void testExtractPathFromVfszipUrl() throws Exception {
-        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
-        final URL url = new URL(
-                "vfszip:/home2/jboss-5.0.1.CR2/jboss-as/server/ais/ais-deploy/myear.ear/mywar.war/WEB-INF/some.xsd");
-        final String expected = "/home2/jboss-5.0.1.CR2/jboss-as/server/ais/ais-deploy/myear.ear/mywar.war/WEB-INF/some.xsd";
-        assertEquals(expected, new ResolverUtil().extractPath(url));
-    }
-
-    @Ignore
-    @Test
-    public void testExtractPathFromVfsUrl() throws Exception {
-        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
-        final URL url = new URL(
-                "vfs:/C:/jboss/jboss-eap-6.4/standalone/deployments/com.xxx.yyy.application-ear.ear/lib/com.xxx.yyy.logging.jar/com/xxx/yyy/logging/config/");
-        final String expected = "/jboss/jboss-eap-6.4/standalone/deployments/com.xxx.yyy.application-ear.ear/lib/com.xxx.yyy.logging.jar/com/xxx/yyy/logging/config/";
-        assertEquals(expected, new ResolverUtil().extractPath(url));
-    }
-
-    @Ignore
-    @Test
-    public void testExtractPathFromVfszipUrlWithPlusCharacters()
-            throws Exception {
-        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
-        final URL url = new URL("vfszip:/path+with+plus/file+name+with+plus.xml");
-        final String expected = "/path+with+plus/file+name+with+plus.xml";
-        assertEquals(expected, new ResolverUtil().extractPath(url));
-    }
-
-    @Ignore
-    @Test
-    public void testExtractPathFromVfsUrlWithPlusCharacters()
-            throws Exception {
-        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
-        final URL url = new URL("vfs:/path+with+plus/file+name+with+plus.xml");
-        final String expected = "/path+with+plus/file+name+with+plus.xml";
-        assertEquals(expected, new ResolverUtil().extractPath(url));
-    }
-
-    @Ignore
-    @Test
-    public void testExtractPathFromResourceBundleUrl() throws Exception {
-        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
-        final URL url = new URL("resourcebundle:/some/path/some/file.properties");
-        final String expected = "/some/path/some/file.properties";
-        assertEquals(expected, new ResolverUtil().extractPath(url));
-    }
-
-    @Ignore
-    @Test
-    public void testExtractPathFromResourceBundleUrlWithPlusCharacters() throws Exception {
-        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
-        final URL url = new URL("resourcebundle:/some+path/some+file.properties");
-        final String expected = "/some+path/some+file.properties";
-        assertEquals(expected, new ResolverUtil().extractPath(url));
-    }
-
     @Test
     public void testExtractPathFromHttpUrl() throws Exception {
         final URL url = new URL("http://java.sun.com/index.html#chapter1");
@@ -186,4 +139,77 @@ public class ResolverUtilTest {
         assertEquals(expected, new ResolverUtil().extractPath(url));
     }
 
+    @Test
+    public void testFindInPackageFromDirectoryPath() throws Exception {
+      ClassLoader cl = compileAndCreateClassLoader("1");
+
+      ResolverUtil resolverUtil = new ResolverUtil();
+      resolverUtil.setClassLoader(cl);
+      resolverUtil.findInPackage(new PluginTest(), "customplugin1");
+      assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+      assertEquals("Unexpected class resolved",
+            cl.loadClass("customplugin1.FixedString1Layout"),
+            resolverUtil.getClasses().iterator().next());
+    }
+
+    @Test
+    public void testFindInPackageFromJarPath() throws Exception {
+      ClassLoader cl = compileJarAndCreateClassLoader("2");
+
+      ResolverUtil resolverUtil = new ResolverUtil();
+      resolverUtil.setClassLoader(cl);
+      resolverUtil.findInPackage(new PluginTest(), "customplugin2");
+      assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+      assertEquals("Unexpected class resolved",
+            cl.loadClass("customplugin2.FixedString2Layout"),
+            resolverUtil.getClasses().iterator().next());
+    }
+
+    static URLClassLoader compileJarAndCreateClassLoader(String suffix) throws IOException, Exception {
+        File workDir = compile(suffix);
+        File jarFile = new File(workDir, "customplugin" + suffix + ".jar");
+        URI jarURL = jarFile.toURI();
+        createJar(jarURL, workDir, new File(workDir,
+              "customplugin" + suffix + "/FixedString" + suffix + "Layout.class"));
+        return URLClassLoader.newInstance(new URL[] {jarURL.toURL()});
+    }
+
+    static URLClassLoader compileAndCreateClassLoader(String suffix) throws IOException {
+        final File workDir = compile(suffix);
+        return URLClassLoader.newInstance(new URL[] {workDir.toURI().toURL()});
+    }
+
+    static File compile(String suffix) throws IOException {
+        final File orig = new File("target/test-classes/customplugin/FixedStringLayout.java.source");
+        final File workDir = new File("target/resolverutil" + suffix);
+        final File javaFile = new File(workDir, "customplugin" + suffix + "/FixedString" + suffix + "Layout.java");
+        final File parent = javaFile.getParentFile();
+        if (!parent.exists()) {
+          assertTrue("Create customplugin" + suffix + " folder KO", javaFile.getParentFile().mkdirs());
+        }
+  
+        String content = new String(Files.readAllBytes(orig.toPath()))
+          .replaceAll("FixedString", "FixedString" + suffix)
+          .replaceAll("customplugin", "customplugin" + suffix);
+        Files.write(javaFile.toPath(), content.getBytes());
+  
+        PluginManagerPackagesTest.compile(javaFile);
+        return workDir;
+    }
+
+    static void createJar(URI jarURL, File workDir, File f) throws Exception {
+        Map<String, String> env = new HashMap<>(); 
+        env.put("create", "true");
+        URI uri = URI.create("jar:file://" + jarURL.getPath());
+        try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) {   
+            Path path = zipfs.getPath(workDir.toPath().relativize(f.toPath()).toString());
+            if (path.getParent() != null) {
+                Files.createDirectories(path.getParent());
+            }
+            Files.copy(f.toPath(),
+                   path, 
+                   StandardCopyOption.REPLACE_EXISTING ); 
+        } 
+    }
+
 }


[37/42] logging-log4j2 git commit: Javadoc: Use the active voice.

Posted by rp...@apache.org.
Javadoc: Use the active voice.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: bc085f22a5c43d61355ee31154b57a9612173799
Parents: 82032fc
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 21:52:29 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 21:52:29 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bc085f22/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
index 8072e7c..f63e416 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
@@ -35,13 +35,13 @@ import org.apache.logging.log4j.core.util.KeyValuePair;
 import org.apache.logging.log4j.message.Message;
 
 /**
- * Compare against a log level that is associated with an MDC value.
+ * Compares against a log level that is associated with an MDC value.
  */
 @Plugin(name = "DynamicThresholdFilter", category = Node.CATEGORY, elementType = Filter.ELEMENT_TYPE, printObject = true)
 public final class DynamicThresholdFilter extends AbstractFilter {
 
     /**
-     * Create the DynamicThresholdFilter.
+     * Creates a DynamicThresholdFilter.
      * @param key The name of the key to compare.
      * @param pairs An array of value and Level pairs.
      * @param defaultThreshold The default Level.


[38/42] logging-log4j2 git commit: Format nits.

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

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 13feb49a0a6576fc835db9fae79b0aab297c5730
Parents: bc085f2
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 21:53:27 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 21:53:27 2016 -0700

----------------------------------------------------------------------
 .../apache/logging/log4j/core/filter/DynamicThresholdFilter.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/13feb49a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
index f63e416..2a2d54c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
@@ -63,9 +63,9 @@ public final class DynamicThresholdFilter extends AbstractFilter {
         final Level level = defaultThreshold == null ? Level.ERROR : defaultThreshold;
         return new DynamicThresholdFilter(key, map, level, onMatch, onMismatch);
     }
+    
     private Level defaultThreshold = Level.ERROR;
     private final String key;
-
     private Map<String, Level> levelMap = new HashMap<>();
 
     private DynamicThresholdFilter(final String key, final Map<String, Level> pairs, final Level defaultLevel,


[02/42] logging-log4j2 git commit: First commit for branch for [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext.

Posted by rp...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfiguration.java
index 6350a48..ed7e9ba 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.config.yaml;
 
 import java.io.IOException;
 
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
 import org.apache.logging.log4j.core.config.json.JsonConfiguration;
@@ -28,8 +29,8 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
 
 public class YamlConfiguration extends JsonConfiguration {
 
-    public YamlConfiguration(final ConfigurationSource configSource) {
-        super(configSource);
+    public YamlConfiguration(final LoggerContext loggerContext, final ConfigurationSource configSource) {
+        super(loggerContext, configSource);
     }
 
     @Override
@@ -44,7 +45,7 @@ public class YamlConfiguration extends JsonConfiguration {
             if (source == null) {
                 return null;
             }
-            return new YamlConfiguration(source);
+            return new YamlConfiguration(getLoggerContext(), source);
         } catch (final IOException ex) {
             LOGGER.error("Cannot locate file {}", getConfigurationSource(), ex);
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
index f3429bb..5d7b1f5 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YamlConfigurationFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.logging.log4j.core.config.yaml;
 
+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.ConfigurationSource;
@@ -58,11 +59,11 @@ public class YamlConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
+    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
         if (!isActive) {
             return null;
         }
-        return new YamlConfiguration(source);
+        return new YamlConfiguration(loggerContext, source);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
index 12b1204..f7b4a83 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
@@ -173,7 +173,7 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba
         if (ctx.getState() == LifeCycle.State.INITIALIZED) {
             if (source != null) {
                 ContextAnchor.THREAD_CONTEXT.set(ctx);
-                final Configuration config = ConfigurationFactory.getInstance().getConfiguration(source);
+                final Configuration config = ConfigurationFactory.getInstance().getConfiguration(ctx, source);
                 LOGGER.debug("Starting LoggerContext[name={}] from configuration {}", ctx.getName(), source);
                 ctx.start(config);
                 ContextAnchor.THREAD_CONTEXT.remove();
@@ -234,7 +234,7 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba
         if (ctx.getState() == LifeCycle.State.INITIALIZED) {
             if (configLocation != null || name != null) {
                 ContextAnchor.THREAD_CONTEXT.set(ctx);
-                final Configuration config = ConfigurationFactory.getInstance().getConfiguration(name, configLocation);
+                final Configuration config = ConfigurationFactory.getInstance().getConfiguration(ctx, name, configLocation);
                 LOGGER.debug("Starting LoggerContext[name={}] from configuration at {}", ctx.getName(), configLocation);
                 ctx.start(config);
                 ContextAnchor.THREAD_CONTEXT.remove();
@@ -261,7 +261,7 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba
                 final List<AbstractConfiguration> configurations = new ArrayList<>(configLocations.size());
                 for (final URI configLocation : configLocations) {
                     final Configuration currentReadConfiguration = ConfigurationFactory.getInstance()
-                            .getConfiguration(name, configLocation);
+                            .getConfiguration(ctx, name, configLocation);
                     if (currentReadConfiguration instanceof AbstractConfiguration) {
                         configurations.add((AbstractConfiguration) currentReadConfiguration);
                     } else {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
index c9ddb90..a2a9288 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
@@ -132,7 +132,7 @@ public class LoggerContextAdmin extends NotificationBroadcasterSupport implement
             LOGGER.debug("Opening config URL {}", configURL);
             configSource = new ConfigurationSource(configURL.openStream(), configURL);
         }
-        final Configuration config = ConfigurationFactory.getInstance().getConfiguration(configSource);
+        final Configuration config = ConfigurationFactory.getInstance().getConfiguration(loggerContext, configSource);
         loggerContext.start(config);
         LOGGER.debug("Completed remote request to reconfigure.");
     }
@@ -197,7 +197,7 @@ public class LoggerContextAdmin extends NotificationBroadcasterSupport implement
         try {
             final InputStream in = new ByteArrayInputStream(configText.getBytes(charsetName));
             final ConfigurationSource source = new ConfigurationSource(in);
-            final Configuration updated = ConfigurationFactory.getInstance().getConfiguration(source);
+            final Configuration updated = ConfigurationFactory.getInstance().getConfiguration(loggerContext, source);
             loggerContext.start(updated);
             LOGGER.debug("Completed remote request to reconfigure from config text.");
         } catch (final Exception ex) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
index af2ca0f..7350e6d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
@@ -29,6 +29,7 @@ import java.util.Objects;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEventListener;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
 import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
@@ -57,7 +58,7 @@ public abstract class AbstractSocketServer<T extends InputStream> extends LogEve
         }
 
         @Override
-        public Configuration getConfiguration(final String name, final URI configLocation) {
+        public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
             if (Strings.isNotEmpty(path)) {
                 File file = null;
                 ConfigurationSource source = null;
@@ -81,14 +82,14 @@ public abstract class AbstractSocketServer<T extends InputStream> extends LogEve
 
                 try {
                     if (source != null) {
-                        return new XmlConfiguration(source);
+                        return new XmlConfiguration(loggerContext, source);
                     }
                 } catch (final Exception ex) {
                     // Ignore this error.
                 }
                 System.err.println("Unable to process configuration at " + path + ", using default.");
             }
-            return super.getConfiguration(name, configLocation);
+            return super.getConfiguration(loggerContext, name, configLocation);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
index 844192f..6c6f56a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
 public class BasicConfigurationFactory extends ConfigurationFactory {
 
     @Override
-    public Configuration getConfiguration(final String name, final URI configLocation) {
+    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
         return new BasicConfiguration();
     }
 
@@ -41,7 +41,7 @@ public class BasicConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
+    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
         return null;
     }
 
@@ -50,7 +50,7 @@ public class BasicConfigurationFactory extends ConfigurationFactory {
         private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
 
         public BasicConfiguration() {
-            super(ConfigurationSource.NULL_SOURCE);
+            super(null, ConfigurationSource.NULL_SOURCE);
 
             final LoggerConfig root = getRootLogger();
             final String name = System.getProperty(DEFAULT_LEVEL);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
index 4cfe7c3..0c7c569 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
@@ -101,6 +101,12 @@ public class ConfigurationTest {
     }
 
     @Test
+    public void testConfigurationLoggerContext() throws Exception {
+        final Configuration configuration = this.ctx.getConfiguration();
+        assertThat(configuration.getLoggerContext(), is(notNullValue()));
+    }
+
+    @Test
     public void testGetLoggerConfigEmpty() throws Exception {
         final Configuration config = this.ctx.getConfiguration();
         assertEquals(config.getRootLogger(), config.getLoggerConfig(Strings.EMPTY));

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/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 d68b40f..126b0f9 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
@@ -16,8 +16,11 @@
  */
 package org.apache.logging.log4j.core.config.builder;
 
+import java.net.URI;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.ConsoleAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
@@ -26,8 +29,6 @@ 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.impl.BuiltConfiguration;
 
-import java.net.URI;
-
 /**
  * Normally this would be a plugin. However, we don't want it used for everything so it will be defined
  * via a system property.
@@ -57,12 +58,12 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
-        return getConfiguration(source.toString(), null);
+    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+        return getConfiguration(null, source.toString(), null);
     }
 
     @Override
-    public Configuration getConfiguration(final String name, final URI configLocation) {
+    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
         final ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder();
         return addTestFixtures(name, builder);
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
index bd34b52..11815cb 100644
--- a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
+++ b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
@@ -16,9 +16,12 @@
  */
 package org.apache.logging.log4j.configuration;
 
+import java.io.Serializable;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.ConsoleAppender;
 import org.apache.logging.log4j.core.config.AbstractConfiguration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
@@ -26,8 +29,6 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
 import org.apache.logging.log4j.core.layout.PatternLayout;
 import org.apache.logging.log4j.util.PropertiesUtil;
 
-import java.io.Serializable;
-
 /**
  * This Configuration is the same as the DefaultConfiguration but shows how a custom configuration can be built
  * programmatically
@@ -50,15 +51,15 @@ public class CustomConfiguration extends AbstractConfiguration {
      */
     public static final String DEFAULT_PATTERN = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n";
 
-    public CustomConfiguration() {
-        this(ConfigurationSource.NULL_SOURCE);
+    public CustomConfiguration(LoggerContext loggerContext) {
+        this(loggerContext, ConfigurationSource.NULL_SOURCE);
     }
 
     /**
      * Constructor to create the default configuration.
      */
-    public CustomConfiguration(final ConfigurationSource source) {
-        super(source);
+    public CustomConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+        super(loggerContext, source);
 
         setName(CONFIG_NAME);
         final Layout<? extends Serializable> layout = PatternLayout.newBuilder()

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
index 7ef0d92..642abe4 100644
--- a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
+++ b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfigurationFactory.java
@@ -16,12 +16,14 @@
  */
 package org.apache.logging.log4j.configuration;
 
+import java.net.URI;
+
+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.ConfigurationSource;
 import org.apache.logging.log4j.core.config.Order;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
-import java.net.URI;
 
 /**
  * Factory to construct a  CustomConfiguration.
@@ -41,13 +43,13 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
      * @return The Configuration.
      */
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
-        return new CustomConfiguration(source);
+    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+        return new CustomConfiguration(loggerContext, source);
     }
 
     @Override
-    public Configuration getConfiguration(final String name, final URI configLocation) {
-        return new CustomConfiguration();
+    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
+        return new CustomConfiguration(loggerContext);
     }
 
     /**


[08/42] logging-log4j2 git commit: Code clean-up

Posted by rp...@apache.org.
Code clean-up


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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: fadd676ea2b149fdf725a028646cf1247398bdcf
Parents: 33aaf3d
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Thu Aug 25 21:30:21 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Thu Aug 25 21:40:09 2016 +0200

----------------------------------------------------------------------
 .../log4j/config/Log4j1ConfigurationParser.java | 172 +++++++++----------
 1 file changed, 80 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fadd676e/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
index f98f909..11f7f76 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationParser.java
@@ -50,9 +50,14 @@ import java.util.Properties;
  * <li>layout</li>
  * </ul>
  * </ul>
+ *
+ * This class is not thread-safe.
  */
 public class Log4j1ConfigurationParser {
 
+    private final Properties properties = new Properties();
+    private final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
+
     /**
      * Parse a Log4j 1.2 properties configuration file into a ConfigurationBuilder.
      *
@@ -60,48 +65,39 @@ public class Log4j1ConfigurationParser {
      * @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();
+    public ConfigurationBuilder<BuiltConfiguration> buildConfigurationBuilder(final InputStream input) throws IOException {
         properties.load(input);
-        final String rootCategoryValue = getRootCategoryValue(properties);
-        final String rootLoggerValue = getRootLoggerValue(properties);
+        final String rootCategoryValue = getLog4jValue("rootCategory");
+        final String rootLoggerValue = getLog4jValue("rootLogger");
         if (rootCategoryValue == null && rootLoggerValue == null) {
             // This is not a Log4j 1 properties configuration file.
             return null;
         }
+        builder.setConfigurationName("Log4j1");
         // DEBUG
-        final String debugValue = getLog4jValue(properties, "debug");
+        final String debugValue = getLog4jValue("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[] sortedAppenderNamesC = buildRootLogger(getLog4jValue("rootCategory"));
+        final String[] sortedAppenderNamesL = buildRootLogger(getLog4jValue("rootLogger"));
         final String[] sortedAppenderNames = sortedAppenderNamesL.length > 0 ? sortedAppenderNamesL
                 : sortedAppenderNamesC;
         // Appenders
-        final Map<String, String> classNameToProperty = buildClassToPropertyPrefixMap(properties, sortedAppenderNames);
+        final Map<String, String> classNameToProperty = buildClassToPropertyPrefixMap(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.");
-            }
+            String appenderClass = entry.getValue();
+            buildAppender(appenderName, appenderClass);
         }
         // Loggers
-        buildLoggers(properties, "log4j.category.", builder);
-        buildLoggers(properties, "log4j.logger.", builder);
+        buildLoggers("log4j.category.");
+        buildLoggers("log4j.logger.");
         return builder;
     }
 
-    private Map<String, String> buildClassToPropertyPrefixMap(final Properties properties,
-                                                              final String[] sortedAppenderNames) {
+    private Map<String, String> buildClassToPropertyPrefixMap(final String[] sortedAppenderNames) {
         final String prefix = "log4j.appender.";
         final int preLength = prefix.length();
         final Map<String, String> map = new HashMap<>(sortedAppenderNames.length);
@@ -125,23 +121,56 @@ public class Log4j1ConfigurationParser {
         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);
+    private void buildAppender(final String appenderName, final String appenderClass) {
+        switch (appenderClass) {
+        case "org.apache.log4j.ConsoleAppender":
+            buildConsoleAppender(appenderName);
+            break;
+        default:
+            reportWarning("Unknown appender class: " + appenderClass + "; ignoring appender: " + appenderName);
+        }
+    }
+
+    private void buildConsoleAppender(final String appenderName) {
+        final AppenderComponentBuilder appenderBuilder = builder.newAppender(appenderName, "Console");
+        final String targetValue = getLog4jAppenderValue(appenderName, "Target", "System.out");
+        if (targetValue != null) {
+            final ConsoleAppender.Target target;
+            switch (targetValue) {
+            case "System.out":
+                target = ConsoleAppender.Target.SYSTEM_OUT;
+                break;
+            case "System.err":
+                target = ConsoleAppender.Target.SYSTEM_ERR;
+                break;
+            default:
+                reportWarning("Unknown value for console Target: " + targetValue);
+                target = null;
+            }
+            if (target != null) {
+                appenderBuilder.addAttribute("target", target);
+            }
+        }
+        buildAppenderAttribute(appenderName, appenderBuilder, "Follow", "false", "follow");
+        buildAppenderLayout(appenderName, 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) {
+    private void buildAppenderAttribute(String appenderName, AppenderComponentBuilder appenderBuilder,
+                                        String sourceAttributeName, String defaultValue, String targetAttributeName) {
+        final String attributeValue = getLog4jAppenderValue(appenderName, sourceAttributeName, defaultValue);
+        if (attributeValue != null) {
+            appenderBuilder.addAttribute(targetAttributeName, attributeValue);
+        }
+    }
+
+    private void buildAppenderLayout(final String name, final AppenderComponentBuilder appenderBuilder) {
+        final String layoutClass = getLog4jAppenderValue(name, "layout", null);
+        if (layoutClass != null) {
+            switch (layoutClass) {
             case "org.apache.log4j.PatternLayout":
             case "org.apache.log4j.EnhancedPatternLayout": {
-                final String pattern = getLog4jAppenderValue(properties, name, "layout.ConversionPattern", null)
+                final String pattern = getLog4jAppenderValue(name, "layout.ConversionPattern", null)
 
                     // Log4j 2's %x (NDC) is not compatible with Log4j 1's %x
                     //   Log4j 1: "foo bar baz"
@@ -155,55 +184,54 @@ public class Log4j1ConfigurationParser {
                     // Use %properties to get the Log4j 1 format
                     .replace("%X", "%properties");
 
-                appenderBuilder.add(newPatternLayout(builder, pattern));
+                appenderBuilder.add(newPatternLayout(pattern));
                 break;
             }
             case "org.apache.log4j.SimpleLayout": {
-                appenderBuilder.add(newPatternLayout(builder, "%level - %m%n"));
+                appenderBuilder.add(newPatternLayout("%level - %m%n"));
                 break;
             }
             case "org.apache.log4j.TTCCLayout": {
                 String pattern = "%r ";
-                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.ThreadPrinting", "true"))) {
+                if (Boolean.parseBoolean(getLog4jAppenderValue(name, "layout.ThreadPrinting", "true"))) {
                     pattern += "[%t] ";
                 }
                 pattern += "%p ";
-                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.CategoryPrefixing", "true"))) {
+                if (Boolean.parseBoolean(getLog4jAppenderValue(name, "layout.CategoryPrefixing", "true"))) {
                     pattern += "%c ";
                 }
-                if (Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.ContextPrinting", "true"))) {
+                if (Boolean.parseBoolean(getLog4jAppenderValue(name, "layout.ContextPrinting", "true"))) {
                     pattern += "%notEmpty{%ndc }";
                 }
                 pattern += "- %m%n";
-                appenderBuilder.add(newPatternLayout(builder, pattern));
+                appenderBuilder.add(newPatternLayout(pattern));
                 break;
             }
             case "org.apache.log4j.HTMLLayout": {
                 LayoutComponentBuilder htmlLayout = builder.newLayout("HtmlLayout");
                 htmlLayout.addAttribute("title",
-                        getLog4jAppenderValue(properties, name, "layout.Title", "Log4J Log Messages"));
+                        getLog4jAppenderValue(name, "layout.Title", "Log4J Log Messages"));
                 htmlLayout.addAttribute("locationInfo",
-                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.LocationInfo", "false")));
+                        Boolean.parseBoolean(getLog4jAppenderValue(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")));
+                        Boolean.parseBoolean(getLog4jAppenderValue(name, "layout.LocationInfo", "false")));
                 xmlLayout.addAttribute("properties",
-                        Boolean.parseBoolean(getLog4jAppenderValue(properties, name, "layout.Properties", "false")));
+                        Boolean.parseBoolean(getLog4jAppenderValue(name, "layout.Properties", "false")));
                 appenderBuilder.add(xmlLayout);
                 break;
             }
             default:
-                reportWarning("Unsupported layout: " + layoutValue);
+                reportWarning("Unknown layout class: " + layoutClass);
             }
         }
     }
 
-    private LayoutComponentBuilder newPatternLayout(final ConfigurationBuilder<BuiltConfiguration> builder,
-            final String pattern) {
+    private LayoutComponentBuilder newPatternLayout(final String pattern) {
         final LayoutComponentBuilder layoutBuilder = builder.newLayout("PatternLayout");
         if (pattern != null) {
             layoutBuilder.addAttribute("pattern", pattern);
@@ -211,38 +239,7 @@ public class Log4j1ConfigurationParser {
         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) {
+    private String[] buildRootLogger(final String rootLoggerValue) {
         if (rootLoggerValue == null) {
             return new String[0];
         }
@@ -258,8 +255,7 @@ public class Log4j1ConfigurationParser {
         return sortedAppenderNames;
     }
 
-    private void buildLoggers(final Properties properties, final String prefix,
-            final ConfigurationBuilder<BuiltConfiguration> builder) {
+    private void buildLoggers(final String prefix) {
         final int preLength = prefix.length();
         for (final Map.Entry<Object, Object> entry : properties.entrySet()) {
             final Object keyObj = entry.getKey();
@@ -277,23 +273,15 @@ public class Log4j1ConfigurationParser {
 
     }
 
-    private String getLog4jAppenderValue(final Properties properties, final String appenderName,
-            final String attributeName, final String defaultValue) {
+    private String getLog4jAppenderValue(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) {
+    private String getLog4jValue(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);
     }


[33/42] logging-log4j2 git commit: [LOG4J2-1548] [CronTriggeringPolicy] ConfigurationScheduler schedules the task infinitely after first fire. Better test from Pierrick HYMBERT: Added a constant RollingAppenderCronOnceADayTest.CRON_DELAY set to 10 second

Posted by rp...@apache.org.
[LOG4J2-1548] [CronTriggeringPolicy] ConfigurationScheduler schedules
the task infinitely after first fire. Better test from Pierrick HYMBERT:
Added a constant RollingAppenderCronOnceADayTest.CRON_DELAY set to 10
seconds (instead of 45s previously). Checked that test still failed in
this condition with previous revision of
ConfigurationScheduler.CronRunnable.run(). Test is run in 18s on
Pierrick HYMBERT's environment and cron rename action is scheduled. Test
ran in 17.645 in my Eclipse environment. Full Maven build  with 'mvn
clean test' is .

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 3e55d6817ac54f0b0890bc2cc0367855e0487c1e
Parents: 38f1497
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 12:28:23 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 12:28:23 2016 -0700

----------------------------------------------------------------------
 .../appender/rolling/RollingAppenderCronOnceADayTest.java   | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3e55d681/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
index 2e091c4..b6ee09d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
@@ -46,6 +46,7 @@ import org.junit.rules.RuleChain;
  */
 public class RollingAppenderCronOnceADayTest {
 
+    private static final int CRON_DELAY = 10;
     private static final String UTF_8 = "UTF-8";
     private static final String CONFIG = "log4j-rolling-cron-once-a-day.xml";
     private static final String CONFIG_TARGET = "log4j-rolling-cron-once-a-day-target.xml";
@@ -62,7 +63,7 @@ public class RollingAppenderCronOnceADayTest {
       final Path src = FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG);
       String content = new String(Files.readAllBytes(src), UTF_8);
       Calendar cal = Calendar.getInstance();
-      cal.add(Calendar.SECOND, 45);
+      cal.add(Calendar.SECOND, CRON_DELAY);
       remainingTime = cal.getTimeInMillis() - System.currentTimeMillis();
       cronExpression =  String.format("%d %d %d * * ?",
           cal.get(Calendar.SECOND),
@@ -104,11 +105,7 @@ public class RollingAppenderCronOnceADayTest {
         final File dir = new File(DIR);
         assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
 
-        for (int i = 1; i < 20; i++) {
-          logger.debug("Adding again event {}", i);
-        }
-        Thread.sleep(1000);
-        for (int i = 1; i < 10; i++) {
+        for (int i = 1; i < 5; i++) {
           logger.debug("Adding some more event {}", i);
           Thread.sleep(1000);
         }


[16/42] 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/1db38fc4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1db38fc4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1db38fc4

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 1db38fc42fac86f8da408e5450b0b3069ffe5caa
Parents: e15d0c7 cc0bf0b
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 13:52:41 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 13:52:41 2016 -0700

----------------------------------------------------------------------
 .../log4j/config/Log4j1ConfigurationParser.java | 210 +++++++++++--------
 .../config/Log4j1ConfigurationFactoryTest.java  |  25 ++-
 ...g4j-console-EnhancedPatternLayout.properties |   1 -
 .../log4j-console-HtmlLayout.properties         |   1 -
 .../log4j-console-PatternLayout.properties      |   1 -
 .../log4j-console-SimpleLayout.properties       |   1 -
 .../log4j-console-TTCCLayout.properties         |   1 -
 .../log4j-console-XmlLayout.properties          |   1 -
 .../log4j-file-SimpleLayout.properties          |  17 ++
 9 files changed, 158 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1db38fc4/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
----------------------------------------------------------------------


[22/42] logging-log4j2 git commit: Remove unused imports.

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

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 095a4bdbcdf6723145ea97dafaca787a5638ef3f
Parents: 2feacc2
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 21:51:01 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 21:51:01 2016 -0700

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/appender/ConsoleAppender.java  | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/095a4bdb/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
index eed9319..d3f8fe9 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
@@ -29,13 +29,9 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.appender.FileAppender.Builder;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
 import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
 import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
 import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
 import org.apache.logging.log4j.core.layout.PatternLayout;
 import org.apache.logging.log4j.core.util.Booleans;


[15/42] logging-log4j2 git commit: Merge remote-tracking branch 'origin/master'

Posted by rp...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: cc0bf0b46232a88dc7b83a68183f6987b2809422
Parents: 3aceb2a e033027
Author: Mikael St�ldal <mi...@staldal.nu>
Authored: Thu Aug 25 22:29:13 2016 +0200
Committer: Mikael St�ldal <mi...@staldal.nu>
Committed: Thu Aug 25 22:29:13 2016 +0200

----------------------------------------------------------------------
 .../core/config/plugins/util/ResolverUtil.java  |  11 +-
 .../plugins/util/PluginManagerPackagesTest.java |   2 +-
 .../util/ResolverUtilCustomProtocolTest.java    | 208 +++++++++++++++++++
 .../config/plugins/util/ResolverUtilTest.java   | 146 +++++++------
 .../junit/URLStreamHandlerFactoryRule.java      |  96 +++++++++
 src/changes/changes.xml                         |   2 +-
 6 files changed, 400 insertions(+), 65 deletions(-)
----------------------------------------------------------------------



[21/42] logging-log4j2 git commit: Minor Javadoc.

Posted by rp...@apache.org.
Minor Javadoc.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 2feacc2b466faa3d4673c9933715678dc13174ee
Parents: 29e7bfd
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Aug 25 20:43:08 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Aug 25 20:43:08 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2feacc2b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
index 806451d..af19a0c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
@@ -249,7 +249,7 @@ public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
 
     /**
      * Returns the Configuration obtained using a given ClassLoader.
-     * @param loggerContext TODO
+     * @param loggerContext The logger context
      * @param name The configuration name.
      * @param configLocation A URI representing the location of the configuration.
      * @param loader The default ClassLoader to use. If this is {@code null}, then the


[03/42] logging-log4j2 git commit: First commit for branch for [LOG4J2-1547] The Core AbstractConfiguration should track its LoggerContext.

Posted by rp...@apache.org.
First commit for branch for [LOG4J2-1547]
The Core AbstractConfiguration should track its LoggerContext.

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 85c5e81a4bca677bf02dc9be4f2dff3d1f0450c1
Parents: 24ebb9f
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Aug 23 20:58:38 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Aug 23 20:58:38 2016 -0700

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      |    9 +-
 .../apache/log4j/BasicConfigurationFactory.java |   13 +-
 .../config/Log4j1ConfigurationFactoryTest.java  |    4 +-
 .../logging/log4j/core/LoggerContext.java       |    2 +-
 .../core/config/AbstractConfiguration.java      |   14 +-
 .../log4j/core/config/Configuration.java        |    8 +
 .../log4j/core/config/ConfigurationFactory.java | 1113 +++++++++---------
 .../log4j/core/config/DefaultConfiguration.java |    2 +-
 .../log4j/core/config/NullConfiguration.java    |    2 +-
 .../builder/api/ConfigurationBuilder.java       |    8 +
 .../config/builder/impl/BuiltConfiguration.java |    5 +-
 .../impl/DefaultConfigurationBuilder.java       |   29 +-
 .../composite/CompositeConfiguration.java       |    4 +-
 .../core/config/json/JsonConfiguration.java     |   14 +-
 .../config/json/JsonConfigurationFactory.java   |    5 +-
 .../properties/PropertiesConfiguration.java     |    8 +-
 .../PropertiesConfigurationBuilder.java         |   16 +-
 .../PropertiesConfigurationFactory.java         |   10 +-
 .../log4j/core/config/xml/XmlConfiguration.java |    7 +-
 .../config/xml/XmlConfigurationFactory.java     |    5 +-
 .../core/config/yaml/YamlConfiguration.java     |    7 +-
 .../config/yaml/YamlConfigurationFactory.java   |    5 +-
 .../log4j/core/impl/Log4jContextFactory.java    |    6 +-
 .../log4j/core/jmx/LoggerContextAdmin.java      |    4 +-
 .../core/net/server/AbstractSocketServer.java   |    7 +-
 .../log4j/core/BasicConfigurationFactory.java   |    6 +-
 .../log4j/core/config/ConfigurationTest.java    |    6 +
 .../builder/CustomConfigurationFactory.java     |   11 +-
 .../configuration/CustomConfiguration.java      |   13 +-
 .../CustomConfigurationFactory.java             |   12 +-
 30 files changed, 717 insertions(+), 638 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/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 b1b2dfe..a974ed5 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,6 +16,10 @@
  */
 package org.apache.log4j.config;
 
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationException;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
@@ -23,9 +27,6 @@ import org.apache.logging.log4j.core.config.ConfigurationSource;
 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.
  */
@@ -39,7 +40,7 @@ public class Log4j1ConfigurationFactory extends ConfigurationFactory {
     private static final String[] SUFFIXES = {".properties"};
 
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
+    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
         final ConfigurationBuilder<BuiltConfiguration> builder;
         try (final InputStream configStream = source.getInputStream()) {
             builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(configStream);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
index 49b2f82..aabc1c1 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
@@ -19,6 +19,7 @@ package org.apache.log4j;
 import java.net.URI;
 
 import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.AbstractConfiguration;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
@@ -36,13 +37,13 @@ public class BasicConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
-        return new BasicConfiguration();
+    public Configuration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
+        return new BasicConfiguration(loggerContext);
     }
 
     @Override
-    public Configuration getConfiguration(final String name, final URI configLocation) {
-        return new BasicConfiguration();
+    public Configuration getConfiguration(LoggerContext loggerContext, final String name, final URI configLocation) {
+        return new BasicConfiguration(loggerContext);
     }
 
     public class BasicConfiguration extends AbstractConfiguration {
@@ -51,8 +52,8 @@ public class BasicConfigurationFactory extends ConfigurationFactory {
 
         private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
 
-        public BasicConfiguration() {
-            super(ConfigurationSource.NULL_SOURCE);
+        public BasicConfiguration(final LoggerContext loggerContext) {
+            super(loggerContext, ConfigurationSource.NULL_SOURCE);
 
             final LoggerConfig root = getRootLogger();
             setName("BasicConfiguration");

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
index 9f34563..c045415 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
@@ -36,8 +36,8 @@ public class Log4j1ConfigurationFactoryTest {
     private Layout<?> testConsole(final String configResource) throws Exception {
         final URL configLocation = ClassLoader.getSystemResource(configResource);
         assertNotNull(configLocation);
-        final Configuration configuration = new Log4j1ConfigurationFactory().getConfiguration("test",
-                configLocation.toURI());
+        final Configuration configuration = new Log4j1ConfigurationFactory().getConfiguration(null,
+                "test", configLocation.toURI());
         assertNotNull(configuration);
         final ConsoleAppender appender = configuration.getAppender("Console");
         assertNotNull(appender);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/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 ce78615..7156b7c 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
@@ -572,7 +572,7 @@ public class LoggerContext extends AbstractLifeCycle
         final ClassLoader cl = ClassLoader.class.isInstance(externalContext) ? (ClassLoader) externalContext : null;
         LOGGER.debug("Reconfiguration started for context[name={}] at URI {} ({}) with optional ClassLoader: {}",
                 contextName, configURI, this, cl);
-        final Configuration instance = ConfigurationFactory.getInstance().getConfiguration(contextName, configURI, cl);
+        final Configuration instance = ConfigurationFactory.getInstance().getConfiguration(this, contextName, configURI, cl);
         if (instance == null) {
             LOGGER.error("Reconfiguration failed: No configuration found for '%s' at '%s' in '%s'", contextName, configURI, cl);
         } else {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
index bc42d1f..64ead88 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
+import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -39,6 +40,7 @@ import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.Layout;
 import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.AsyncAppender;
 import org.apache.logging.log4j.core.appender.ConsoleAppender;
 import org.apache.logging.log4j.core.async.AsyncLoggerConfig;
@@ -122,11 +124,14 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
     private final WatchManager watchManager = new WatchManager(configurationScheduler);
     private AsyncLoggerConfigDisruptor asyncLoggerConfigDisruptor;
     private NanoClock nanoClock = new DummyNanoClock();
-
+    private WeakReference<LoggerContext> loggerContext;
+    
     /**
      * Constructor.
      */
-    protected AbstractConfiguration(final ConfigurationSource configurationSource) {
+    protected AbstractConfiguration(LoggerContext loggerContext, final ConfigurationSource configurationSource) {
+        this.loggerContext = new WeakReference<>(loggerContext);
+        //this.loggerContext = new WeakReference(Objects.requireNonNull(loggerContext, "loggerContext is null"));
         this.configurationSource = Objects.requireNonNull(configurationSource, "configurationSource is null");
         componentMap.put(Configuration.CONTEXT_PROPERTIES, properties);
         pluginManager = new PluginManager(Node.CATEGORY);
@@ -787,6 +792,11 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
         return root;
     }
 
+    @Override
+    public LoggerContext getLoggerContext() {
+        return loggerContext.get();
+    }
+    
     /**
      * Returns the root Logger.
      *

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
index 678242c..88be74d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.async.AsyncLoggerConfigDelegate;
 import org.apache.logging.log4j.core.filter.Filterable;
 import org.apache.logging.log4j.core.lookup.StrSubstitutor;
@@ -188,4 +189,11 @@ public interface Configuration extends Filterable {
      * @param nanoClock the new nano clock for this configuration. Must be non-null.
      */
     void setNanoClock(NanoClock nanoClock);
+
+    /**
+     * Gets the logger context.
+     * 
+     * @return the logger context.
+     */
+    LoggerContext getLoggerContext();
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
index 7452dfa..806451d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
@@ -1,553 +1,560 @@
-/*
- * 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.config;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
-import org.apache.logging.log4j.core.config.composite.CompositeConfiguration;
-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.lookup.Interpolator;
-import org.apache.logging.log4j.core.lookup.StrSubstitutor;
-import org.apache.logging.log4j.core.util.FileUtils;
-import org.apache.logging.log4j.core.util.Loader;
-import org.apache.logging.log4j.core.util.NetUtils;
-import org.apache.logging.log4j.core.util.ReflectionUtil;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.apache.logging.log4j.util.PropertiesUtil;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Factory class for parsed {@link Configuration} objects from a configuration file.
- * ConfigurationFactory allows the configuration implementation to be
- * dynamically chosen in 1 of 3 ways:
- * <ol>
- * <li>A system property named "log4j.configurationFactory" can be set with the
- * name of the ConfigurationFactory to be used.</li>
- * <li>
- * {@linkplain #setConfigurationFactory(ConfigurationFactory)} can be called
- * with the instance of the ConfigurationFactory to be used. This must be called
- * before any other calls to Log4j.</li>
- * <li>
- * A ConfigurationFactory implementation can be added to the classpath and configured as a plugin in the
- * {@link #CATEGORY ConfigurationFactory} category. The {@link Order} annotation should be used to configure the
- * factory to be the first one inspected. See
- * {@linkplain org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory} for an example.</li>
- * </ol>
- *
- * If the ConfigurationFactory that was added returns null on a call to
- * getConfiguration then any other ConfigurationFactories found as plugins will
- * be called in their respective order. DefaultConfiguration is always called
- * last if no configuration has been returned.
- */
-public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
-    
-    /**
-     * Allows the ConfigurationFactory class to be specified as a system property.
-     */
-    public static final String CONFIGURATION_FACTORY_PROPERTY = "log4j.configurationFactory";
-
-    /**
-     * Allows the location of the configuration file to be specified as a system property.
-     */
-    public static final String CONFIGURATION_FILE_PROPERTY = "log4j.configurationFile";
-
-    /**
-     * Plugin category used to inject a ConfigurationFactory {@link org.apache.logging.log4j.core.config.plugins.Plugin}
-     * class.
-     *
-     * @since 2.1
-     */
-    public static final String CATEGORY = "ConfigurationFactory";
-
-    /**
-     * Allows subclasses access to the status logger without creating another instance.
-     */
-    protected static final Logger LOGGER = StatusLogger.getLogger();
-
-    /**
-     * File name prefix for test configurations.
-     */
-    protected static final String TEST_PREFIX = "log4j2-test";
-
-    /**
-     * File name prefix for standard configurations.
-     */
-    protected static final String DEFAULT_PREFIX = "log4j2";
-
-    /**
-     * The name of the classloader URI scheme.
-     */
-    private static final String CLASS_LOADER_SCHEME = "classloader";
-
-    /**
-     * The name of the classpath URI scheme, synonymous with the classloader URI scheme.
-     */
-    private static final String CLASS_PATH_SCHEME = "classpath";
-
-    private static volatile List<ConfigurationFactory> factories = null;
-
-    private static ConfigurationFactory configFactory = new Factory();
-
-    protected final StrSubstitutor substitutor = new StrSubstitutor(new Interpolator());
-
-    private static final Lock LOCK = new ReentrantLock();
-
-    /**
-     * Returns the ConfigurationFactory.
-     * @return the ConfigurationFactory.
-     */
-    public static ConfigurationFactory getInstance() {
-        // volatile works in Java 1.6+, so double-checked locking also works properly
-        //noinspection DoubleCheckedLocking
-        if (factories == null) {
-            LOCK.lock();
-            try {
-                if (factories == null) {
-                    final List<ConfigurationFactory> list = new ArrayList<>();
-                    final String factoryClass = PropertiesUtil.getProperties().getStringProperty(CONFIGURATION_FACTORY_PROPERTY);
-                    if (factoryClass != null) {
-                        addFactory(list, factoryClass);
-                    }
-                    final PluginManager manager = new PluginManager(CATEGORY);
-                    manager.collectPlugins();
-                    final Map<String, PluginType<?>> plugins = manager.getPlugins();
-                    final List<Class<? extends ConfigurationFactory>> ordered = new ArrayList<>(plugins.size());
-                    for (final PluginType<?> type : plugins.values()) {
-                        try {
-                            ordered.add(type.getPluginClass().asSubclass(ConfigurationFactory.class));
-                        } catch (final Exception ex) {
-                            LOGGER.warn("Unable to add class {}", type.getPluginClass(), ex);
-                        }
-                    }
-                    Collections.sort(ordered, OrderComparator.getInstance());
-                    for (final Class<? extends ConfigurationFactory> clazz : ordered) {
-                        addFactory(list, clazz);
-                    }
-                    // see above comments about double-checked locking
-                    //noinspection NonThreadSafeLazyInitialization
-                    factories = Collections.unmodifiableList(list);
-                }
-            } finally {
-                LOCK.unlock();
-            }
-        }
-
-        LOGGER.debug("Using configurationFactory {}", configFactory);
-        return configFactory;
-    }
-
-    private static void addFactory(final Collection<ConfigurationFactory> list, final String factoryClass) {
-        try {
-            addFactory(list, LoaderUtil.loadClass(factoryClass).asSubclass(ConfigurationFactory.class));
-        } catch (final Exception ex) {
-            LOGGER.error("Unable to load class {}", factoryClass, ex);
-        }
-    }
-
-    private static void addFactory(final Collection<ConfigurationFactory> list,
-                                   final Class<? extends ConfigurationFactory> factoryClass) {
-        try {
-            list.add(ReflectionUtil.instantiate(factoryClass));
-        } catch (final Exception ex) {
-            LOGGER.error("Unable to create instance of {}", factoryClass.getName(), ex);
-        }
-    }
-
-    /**
-     * Sets the configuration factory. This method is not intended for general use and may not be thread safe.
-     * @param factory the ConfigurationFactory.
-     */
-    public static void setConfigurationFactory(final ConfigurationFactory factory) {
-        configFactory = factory;
-    }
-
-    /**
-     * Resets the ConfigurationFactory to the default. This method is not intended for general use and may
-     * not be thread safe.
-     */
-    public static void resetConfigurationFactory() {
-        configFactory = new Factory();
-    }
-
-    /**
-     * Removes the ConfigurationFactory. This method is not intended for general use and may not be thread safe.
-     * @param factory The factory to remove.
-     */
-    public static void removeConfigurationFactory(final ConfigurationFactory factory) {
-        if (configFactory == factory) {
-            configFactory = new Factory();
-        }
-    }
-
-    protected abstract String[] getSupportedTypes();
-
-    protected boolean isActive() {
-        return true;
-    }
-
-    public abstract Configuration getConfiguration(ConfigurationSource source);
-
-    /**
-     * Returns the Configuration.
-     * @param name The configuration name.
-     * @param configLocation The configuration location.
-     * @return The Configuration.
-     */
-    public Configuration getConfiguration(final String name, final URI configLocation) {
-        if (!isActive()) {
-            return null;
-        }
-        if (configLocation != null) {
-            final ConfigurationSource source = getInputFromUri(configLocation);
-            if (source != null) {
-                return getConfiguration(source);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Returns the Configuration obtained using a given ClassLoader.
-     *
-     * @param name The configuration name.
-     * @param configLocation A URI representing the location of the configuration.
-     * @param loader The default ClassLoader to use. If this is {@code null}, then the
-     *               {@linkplain LoaderUtil#getThreadContextClassLoader() default ClassLoader} will be used.
-     * @return The Configuration.
-     * @since 2.1
-     */
-    public Configuration getConfiguration(final String name, final URI configLocation, final ClassLoader loader) {
-        if (!isActive()) {
-            return null;
-        }
-        if (loader == null) {
-            return getConfiguration(name, configLocation);
-        }
-        if (isClassLoaderUri(configLocation)) {
-            final String path = extractClassLoaderUriPath(configLocation);
-            final ConfigurationSource source = getInputFromResource(path, loader);
-            if (source != null) {
-                final Configuration configuration = getConfiguration(source);
-                if (configuration != null) {
-                    return configuration;
-                }
-            }
-        }
-        return getConfiguration(name, configLocation);
-    }
-
-    /**
-     * Loads the configuration from a URI.
-     * @param configLocation A URI representing the location of the configuration.
-     * @return The ConfigurationSource for the configuration.
-     */
-    protected ConfigurationSource getInputFromUri(final URI configLocation) {
-        final File configFile = FileUtils.fileFromUri(configLocation);
-        if (configFile != null && configFile.exists() && configFile.canRead()) {
-            try {
-                return new ConfigurationSource(new FileInputStream(configFile), configFile);
-            } catch (final FileNotFoundException ex) {
-                LOGGER.error("Cannot locate file {}", configLocation.getPath(), ex);
-            }
-        }
-        if (isClassLoaderUri(configLocation)) {
-            final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
-            final String path = extractClassLoaderUriPath(configLocation);
-            final ConfigurationSource source = getInputFromResource(path, loader);
-            if (source != null) {
-                return source;
-            }
-        }
-        if (!configLocation.isAbsolute()) { // LOG4J2-704 avoid confusing error message thrown by uri.toURL()
-            LOGGER.error("File not found in file system or classpath: {}", configLocation.toString());
-            return null;
-        }
-        try {
-            return new ConfigurationSource(configLocation.toURL().openStream(), configLocation.toURL());
-        } catch (final MalformedURLException ex) {
-            LOGGER.error("Invalid URL {}", configLocation.toString(), ex);
-        } catch (final Exception ex) {
-            LOGGER.error("Unable to access {}", configLocation.toString(), ex);
-        }
-        return null;
-    }
-
-    private static boolean isClassLoaderUri(final URI uri) {
-        if (uri == null) {
-            return false;
-        }
-        final String scheme = uri.getScheme();
-        return scheme == null || scheme.equals(CLASS_LOADER_SCHEME) || scheme.equals(CLASS_PATH_SCHEME);
-    }
-
-    private static String extractClassLoaderUriPath(final URI uri) {
-        return uri.getScheme() == null ? uri.getPath() : uri.getSchemeSpecificPart();
-    }
-
-    /**
-     * Loads the configuration from the location represented by the String.
-     * @param config The configuration location.
-     * @param loader The default ClassLoader to use.
-     * @return The InputSource to use to read the configuration.
-     */
-    protected ConfigurationSource getInputFromString(final String config, final ClassLoader loader) {
-        try {
-            final URL url = new URL(config);
-            return new ConfigurationSource(url.openStream(), FileUtils.fileFromUri(url.toURI()));
-        } catch (final Exception ex) {
-            final ConfigurationSource source = getInputFromResource(config, loader);
-            if (source == null) {
-                try {
-                    final File file = new File(config);
-                    return new ConfigurationSource(new FileInputStream(file), file);
-                } catch (final FileNotFoundException fnfe) {
-                    // Ignore the exception
-                    LOGGER.catching(Level.DEBUG, fnfe);
-                }
-            }
-            return source;
-        }
-    }
-
-    /**
-     * Retrieves the configuration via the ClassLoader.
-     * @param resource The resource to load.
-     * @param loader The default ClassLoader to use.
-     * @return The ConfigurationSource for the configuration.
-     */
-    protected ConfigurationSource getInputFromResource(final String resource, final ClassLoader loader) {
-        final URL url = Loader.getResource(resource, loader);
-        if (url == null) {
-            return null;
-        }
-        InputStream is = null;
-        try {
-            is = url.openStream();
-        } catch (final IOException ioe) {
-            LOGGER.catching(Level.DEBUG, ioe);
-            return null;
-        }
-        if (is == null) {
-            return null;
-        }
-
-        if (FileUtils.isFile(url)) {
-            try {
-                return new ConfigurationSource(is, FileUtils.fileFromUri(url.toURI()));
-            } catch (final URISyntaxException ex) {
-                // Just ignore the exception.
-                LOGGER.catching(Level.DEBUG, ex);
-            }
-        }
-        return new ConfigurationSource(is, url);
-    }
-
-    /**
-     * Default Factory.
-     */
-    private static class Factory extends ConfigurationFactory {
-
-        private static final String ALL_TYPES = "*";
-
-        /**
-         * Default Factory Constructor.
-         * @param name The configuration name.
-         * @param configLocation The configuration location.
-         * @return The Configuration.
-         */
-        @Override
-        public Configuration getConfiguration(final String name, final URI configLocation) {
-
-            if (configLocation == null) {
-                final String configLocationStr = this.substitutor.replace(PropertiesUtil.getProperties()
-                        .getStringProperty(CONFIGURATION_FILE_PROPERTY));
-                if (configLocationStr != null) {
-                    final String[] sources = configLocationStr.split(",");
-                    if (sources.length > 1) {
-                        final List<AbstractConfiguration> configs = new ArrayList<>();
-                        for (final String sourceLocation : sources) {
-                            final Configuration config = getConfiguration(sourceLocation.trim());
-                            if (config != null && config instanceof AbstractConfiguration) {
-                                configs.add((AbstractConfiguration) config);
-                            } else {
-                                LOGGER.error("Failed to created configuration at {}", sourceLocation);
-                                return null;
-                            }
-                        }
-                        return new CompositeConfiguration(configs);
-                    }
-                    return getConfiguration(configLocationStr);
-                }
-                for (final ConfigurationFactory factory : getFactories()) {
-                    final String[] types = factory.getSupportedTypes();
-                    if (types != null) {
-                        for (final String type : types) {
-                            if (type.equals(ALL_TYPES)) {
-                                final Configuration config = factory.getConfiguration(name, configLocation);
-                                if (config != null) {
-                                    return config;
-                                }
-                            }
-                        }
-                    }
-                }
-            } else {
-                // configLocation != null
-                final String configLocationStr = configLocation.toString();
-                for (final ConfigurationFactory factory : getFactories()) {
-                    final String[] types = factory.getSupportedTypes();
-                    if (types != null) {
-                        for (final String type : types) {
-                            if (type.equals(ALL_TYPES) || configLocationStr.endsWith(type)) {
-                                final Configuration config = factory.getConfiguration(name, configLocation);
-                                if (config != null) {
-                                    return config;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            Configuration config = getConfiguration(true, name);
-            if (config == null) {
-                config = getConfiguration(true, null);
-                if (config == null) {
-                    config = getConfiguration(false, name);
-                    if (config == null) {
-                        config = getConfiguration(false, null);
-                    }
-                }
-            }
-            if (config != null) {
-                return config;
-            }
-            LOGGER.error("No log4j2 configuration file found. Using default configuration: logging only errors to the console.");
-            return new DefaultConfiguration();
-        }
-
-        private Configuration getConfiguration(final String configLocationStr) {
-            ConfigurationSource source = null;
-            try {
-                source = getInputFromUri(NetUtils.toURI(configLocationStr));
-            } catch (final Exception ex) {
-                // Ignore the error and try as a String.
-                LOGGER.catching(Level.DEBUG, ex);
-            }
-            if (source == null) {
-                final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
-                source = getInputFromString(configLocationStr, loader);
-            }
-            if (source != null) {
-                for (final ConfigurationFactory factory : getFactories()) {
-                    final String[] types = factory.getSupportedTypes();
-                    if (types != null) {
-                        for (final String type : types) {
-                            if (type.equals(ALL_TYPES) || configLocationStr.endsWith(type)) {
-                                final Configuration config = factory.getConfiguration(source);
-                                if (config != null) {
-                                    return config;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            return null;
-        }
-
-        private Configuration getConfiguration(final boolean isTest, final String name) {
-            final boolean named = Strings.isNotEmpty(name);
-            final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
-            for (final ConfigurationFactory factory : getFactories()) {
-                String configName;
-                final String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX;
-                final String [] types = factory.getSupportedTypes();
-                if (types == null) {
-                    continue;
-                }
-
-                for (final String suffix : types) {
-                    if (suffix.equals(ALL_TYPES)) {
-                        continue;
-                    }
-                    configName = named ? prefix + name + suffix : prefix + suffix;
-
-                    final ConfigurationSource source = getInputFromResource(configName, loader);
-                    if (source != null) {
-                        return factory.getConfiguration(source);
-                    }
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public String[] getSupportedTypes() {
-            return null;
-        }
-
-        @Override
-        public Configuration getConfiguration(final ConfigurationSource source) {
-            if (source != null) {
-                final String config = source.getLocation();
-                for (final ConfigurationFactory factory : getFactories()) {
-                    final String[] types = factory.getSupportedTypes();
-                    if (types != null) {
-                        for (final String type : types) {
-                            if (type.equals(ALL_TYPES) || config != null && config.endsWith(type)) {
-                                final Configuration c = factory.getConfiguration(source);
-                                if (c != null) {
-                                    LOGGER.debug("Loaded configuration from {}", source);
-                                    return c;
-                                }
-                                LOGGER.error("Cannot determine the ConfigurationFactory to use for {}", config);
-                                return null;
-                            }
-                        }
-                    }
-                }
-            }
-            LOGGER.error("Cannot process configuration, input source is null");
-            return null;
-        }
-    }
-
-    static List<ConfigurationFactory> getFactories() {
-        return factories;
-    }
-}
+/*
+ * 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.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
+import org.apache.logging.log4j.core.config.composite.CompositeConfiguration;
+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.lookup.Interpolator;
+import org.apache.logging.log4j.core.lookup.StrSubstitutor;
+import org.apache.logging.log4j.core.util.FileUtils;
+import org.apache.logging.log4j.core.util.Loader;
+import org.apache.logging.log4j.core.util.NetUtils;
+import org.apache.logging.log4j.core.util.ReflectionUtil;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+import org.apache.logging.log4j.util.PropertiesUtil;
+import org.apache.logging.log4j.util.Strings;
+
+/**
+ * Factory class for parsed {@link Configuration} objects from a configuration file.
+ * ConfigurationFactory allows the configuration implementation to be
+ * dynamically chosen in 1 of 3 ways:
+ * <ol>
+ * <li>A system property named "log4j.configurationFactory" can be set with the
+ * name of the ConfigurationFactory to be used.</li>
+ * <li>
+ * {@linkplain #setConfigurationFactory(ConfigurationFactory)} can be called
+ * with the instance of the ConfigurationFactory to be used. This must be called
+ * before any other calls to Log4j.</li>
+ * <li>
+ * A ConfigurationFactory implementation can be added to the classpath and configured as a plugin in the
+ * {@link #CATEGORY ConfigurationFactory} category. The {@link Order} annotation should be used to configure the
+ * factory to be the first one inspected. See
+ * {@linkplain org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory} for an example.</li>
+ * </ol>
+ *
+ * If the ConfigurationFactory that was added returns null on a call to
+ * getConfiguration then any other ConfigurationFactories found as plugins will
+ * be called in their respective order. DefaultConfiguration is always called
+ * last if no configuration has been returned.
+ */
+public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
+    
+    public ConfigurationFactory() {
+        super();
+        // TEMP For breakpoints
+    }
+
+    /**
+     * Allows the ConfigurationFactory class to be specified as a system property.
+     */
+    public static final String CONFIGURATION_FACTORY_PROPERTY = "log4j.configurationFactory";
+
+    /**
+     * Allows the location of the configuration file to be specified as a system property.
+     */
+    public static final String CONFIGURATION_FILE_PROPERTY = "log4j.configurationFile";
+
+    /**
+     * Plugin category used to inject a ConfigurationFactory {@link org.apache.logging.log4j.core.config.plugins.Plugin}
+     * class.
+     *
+     * @since 2.1
+     */
+    public static final String CATEGORY = "ConfigurationFactory";
+
+    /**
+     * Allows subclasses access to the status logger without creating another instance.
+     */
+    protected static final Logger LOGGER = StatusLogger.getLogger();
+
+    /**
+     * File name prefix for test configurations.
+     */
+    protected static final String TEST_PREFIX = "log4j2-test";
+
+    /**
+     * File name prefix for standard configurations.
+     */
+    protected static final String DEFAULT_PREFIX = "log4j2";
+
+    /**
+     * The name of the classloader URI scheme.
+     */
+    private static final String CLASS_LOADER_SCHEME = "classloader";
+
+    /**
+     * The name of the classpath URI scheme, synonymous with the classloader URI scheme.
+     */
+    private static final String CLASS_PATH_SCHEME = "classpath";
+
+    private static volatile List<ConfigurationFactory> factories = null;
+
+    private static ConfigurationFactory configFactory = new Factory();
+
+    protected final StrSubstitutor substitutor = new StrSubstitutor(new Interpolator());
+
+    private static final Lock LOCK = new ReentrantLock();
+
+    /**
+     * Returns the ConfigurationFactory.
+     * @return the ConfigurationFactory.
+     */
+    public static ConfigurationFactory getInstance() {
+        // volatile works in Java 1.6+, so double-checked locking also works properly
+        //noinspection DoubleCheckedLocking
+        if (factories == null) {
+            LOCK.lock();
+            try {
+                if (factories == null) {
+                    final List<ConfigurationFactory> list = new ArrayList<>();
+                    final String factoryClass = PropertiesUtil.getProperties().getStringProperty(CONFIGURATION_FACTORY_PROPERTY);
+                    if (factoryClass != null) {
+                        addFactory(list, factoryClass);
+                    }
+                    final PluginManager manager = new PluginManager(CATEGORY);
+                    manager.collectPlugins();
+                    final Map<String, PluginType<?>> plugins = manager.getPlugins();
+                    final List<Class<? extends ConfigurationFactory>> ordered = new ArrayList<>(plugins.size());
+                    for (final PluginType<?> type : plugins.values()) {
+                        try {
+                            ordered.add(type.getPluginClass().asSubclass(ConfigurationFactory.class));
+                        } catch (final Exception ex) {
+                            LOGGER.warn("Unable to add class {}", type.getPluginClass(), ex);
+                        }
+                    }
+                    Collections.sort(ordered, OrderComparator.getInstance());
+                    for (final Class<? extends ConfigurationFactory> clazz : ordered) {
+                        addFactory(list, clazz);
+                    }
+                    // see above comments about double-checked locking
+                    //noinspection NonThreadSafeLazyInitialization
+                    factories = Collections.unmodifiableList(list);
+                }
+            } finally {
+                LOCK.unlock();
+            }
+        }
+
+        LOGGER.debug("Using configurationFactory {}", configFactory);
+        return configFactory;
+    }
+
+    private static void addFactory(final Collection<ConfigurationFactory> list, final String factoryClass) {
+        try {
+            addFactory(list, LoaderUtil.loadClass(factoryClass).asSubclass(ConfigurationFactory.class));
+        } catch (final Exception ex) {
+            LOGGER.error("Unable to load class {}", factoryClass, ex);
+        }
+    }
+
+    private static void addFactory(final Collection<ConfigurationFactory> list,
+                                   final Class<? extends ConfigurationFactory> factoryClass) {
+        try {
+            list.add(ReflectionUtil.instantiate(factoryClass));
+        } catch (final Exception ex) {
+            LOGGER.error("Unable to create instance of {}", factoryClass.getName(), ex);
+        }
+    }
+
+    /**
+     * Sets the configuration factory. This method is not intended for general use and may not be thread safe.
+     * @param factory the ConfigurationFactory.
+     */
+    public static void setConfigurationFactory(final ConfigurationFactory factory) {
+        configFactory = factory;
+    }
+
+    /**
+     * Resets the ConfigurationFactory to the default. This method is not intended for general use and may
+     * not be thread safe.
+     */
+    public static void resetConfigurationFactory() {
+        configFactory = new Factory();
+    }
+
+    /**
+     * Removes the ConfigurationFactory. This method is not intended for general use and may not be thread safe.
+     * @param factory The factory to remove.
+     */
+    public static void removeConfigurationFactory(final ConfigurationFactory factory) {
+        if (configFactory == factory) {
+            configFactory = new Factory();
+        }
+    }
+
+    protected abstract String[] getSupportedTypes();
+
+    protected boolean isActive() {
+        return true;
+    }
+
+    public abstract Configuration getConfiguration(LoggerContext loggerContext, ConfigurationSource source);
+
+    /**
+     * Returns the Configuration.
+     * @param loggerContext The logger context
+     * @param name The configuration name.
+     * @param configLocation The configuration location.
+     * @return The Configuration.
+     */
+    public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
+        if (!isActive()) {
+            return null;
+        }
+        if (configLocation != null) {
+            final ConfigurationSource source = getInputFromUri(configLocation);
+            if (source != null) {
+                return getConfiguration(loggerContext, source);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns the Configuration obtained using a given ClassLoader.
+     * @param loggerContext TODO
+     * @param name The configuration name.
+     * @param configLocation A URI representing the location of the configuration.
+     * @param loader The default ClassLoader to use. If this is {@code null}, then the
+     *               {@linkplain LoaderUtil#getThreadContextClassLoader() default ClassLoader} will be used.
+     *
+     * @return The Configuration.
+     */
+    public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation, final ClassLoader loader) {
+        if (!isActive()) {
+            return null;
+        }
+        if (loader == null) {
+            return getConfiguration(loggerContext, name, configLocation);
+        }
+        if (isClassLoaderUri(configLocation)) {
+            final String path = extractClassLoaderUriPath(configLocation);
+            final ConfigurationSource source = getInputFromResource(path, loader);
+            if (source != null) {
+                final Configuration configuration = getConfiguration(loggerContext, source);
+                if (configuration != null) {
+                    return configuration;
+                }
+            }
+        }
+        return getConfiguration(loggerContext, name, configLocation);
+    }
+
+    /**
+     * Loads the configuration from a URI.
+     * @param configLocation A URI representing the location of the configuration.
+     * @return The ConfigurationSource for the configuration.
+     */
+    protected ConfigurationSource getInputFromUri(final URI configLocation) {
+        final File configFile = FileUtils.fileFromUri(configLocation);
+        if (configFile != null && configFile.exists() && configFile.canRead()) {
+            try {
+                return new ConfigurationSource(new FileInputStream(configFile), configFile);
+            } catch (final FileNotFoundException ex) {
+                LOGGER.error("Cannot locate file {}", configLocation.getPath(), ex);
+            }
+        }
+        if (isClassLoaderUri(configLocation)) {
+            final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
+            final String path = extractClassLoaderUriPath(configLocation);
+            final ConfigurationSource source = getInputFromResource(path, loader);
+            if (source != null) {
+                return source;
+            }
+        }
+        if (!configLocation.isAbsolute()) { // LOG4J2-704 avoid confusing error message thrown by uri.toURL()
+            LOGGER.error("File not found in file system or classpath: {}", configLocation.toString());
+            return null;
+        }
+        try {
+            return new ConfigurationSource(configLocation.toURL().openStream(), configLocation.toURL());
+        } catch (final MalformedURLException ex) {
+            LOGGER.error("Invalid URL {}", configLocation.toString(), ex);
+        } catch (final Exception ex) {
+            LOGGER.error("Unable to access {}", configLocation.toString(), ex);
+        }
+        return null;
+    }
+
+    private static boolean isClassLoaderUri(final URI uri) {
+        if (uri == null) {
+            return false;
+        }
+        final String scheme = uri.getScheme();
+        return scheme == null || scheme.equals(CLASS_LOADER_SCHEME) || scheme.equals(CLASS_PATH_SCHEME);
+    }
+
+    private static String extractClassLoaderUriPath(final URI uri) {
+        return uri.getScheme() == null ? uri.getPath() : uri.getSchemeSpecificPart();
+    }
+
+    /**
+     * Loads the configuration from the location represented by the String.
+     * @param config The configuration location.
+     * @param loader The default ClassLoader to use.
+     * @return The InputSource to use to read the configuration.
+     */
+    protected ConfigurationSource getInputFromString(final String config, final ClassLoader loader) {
+        try {
+            final URL url = new URL(config);
+            return new ConfigurationSource(url.openStream(), FileUtils.fileFromUri(url.toURI()));
+        } catch (final Exception ex) {
+            final ConfigurationSource source = getInputFromResource(config, loader);
+            if (source == null) {
+                try {
+                    final File file = new File(config);
+                    return new ConfigurationSource(new FileInputStream(file), file);
+                } catch (final FileNotFoundException fnfe) {
+                    // Ignore the exception
+                    LOGGER.catching(Level.DEBUG, fnfe);
+                }
+            }
+            return source;
+        }
+    }
+
+    /**
+     * Retrieves the configuration via the ClassLoader.
+     * @param resource The resource to load.
+     * @param loader The default ClassLoader to use.
+     * @return The ConfigurationSource for the configuration.
+     */
+    protected ConfigurationSource getInputFromResource(final String resource, final ClassLoader loader) {
+        final URL url = Loader.getResource(resource, loader);
+        if (url == null) {
+            return null;
+        }
+        InputStream is = null;
+        try {
+            is = url.openStream();
+        } catch (final IOException ioe) {
+            LOGGER.catching(Level.DEBUG, ioe);
+            return null;
+        }
+        if (is == null) {
+            return null;
+        }
+
+        if (FileUtils.isFile(url)) {
+            try {
+                return new ConfigurationSource(is, FileUtils.fileFromUri(url.toURI()));
+            } catch (final URISyntaxException ex) {
+                // Just ignore the exception.
+                LOGGER.catching(Level.DEBUG, ex);
+            }
+        }
+        return new ConfigurationSource(is, url);
+    }
+
+    /**
+     * Default Factory.
+     */
+    private static class Factory extends ConfigurationFactory {
+
+        private static final String ALL_TYPES = "*";
+
+        /**
+         * Default Factory Constructor.
+         * @param name The configuration name.
+         * @param configLocation The configuration location.
+         * @return The Configuration.
+         */
+        @Override
+        public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) {
+
+            if (configLocation == null) {
+                final String configLocationStr = this.substitutor.replace(PropertiesUtil.getProperties()
+                        .getStringProperty(CONFIGURATION_FILE_PROPERTY));
+                if (configLocationStr != null) {
+                    final String[] sources = configLocationStr.split(",");
+                    if (sources.length > 1) {
+                        final List<AbstractConfiguration> configs = new ArrayList<>();
+                        for (final String sourceLocation : sources) {
+                            final Configuration config = getConfiguration(loggerContext, sourceLocation.trim());
+                            if (config != null && config instanceof AbstractConfiguration) {
+                                configs.add((AbstractConfiguration) config);
+                            } else {
+                                LOGGER.error("Failed to created configuration at {}", sourceLocation);
+                                return null;
+                            }
+                        }
+                        return new CompositeConfiguration(configs);
+                    }
+                    return getConfiguration(loggerContext, configLocationStr);
+                }
+                for (final ConfigurationFactory factory : getFactories()) {
+                    final String[] types = factory.getSupportedTypes();
+                    if (types != null) {
+                        for (final String type : types) {
+                            if (type.equals(ALL_TYPES)) {
+                                final Configuration config = factory.getConfiguration(loggerContext, name, configLocation);
+                                if (config != null) {
+                                    return config;
+                                }
+                            }
+                        }
+                    }
+                }
+            } else {
+                // configLocation != null
+                final String configLocationStr = configLocation.toString();
+                for (final ConfigurationFactory factory : getFactories()) {
+                    final String[] types = factory.getSupportedTypes();
+                    if (types != null) {
+                        for (final String type : types) {
+                            if (type.equals(ALL_TYPES) || configLocationStr.endsWith(type)) {
+                                final Configuration config = factory.getConfiguration(loggerContext, name, configLocation);
+                                if (config != null) {
+                                    return config;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+            Configuration config = getConfiguration(loggerContext, true, name);
+            if (config == null) {
+                config = getConfiguration(loggerContext, true, null);
+                if (config == null) {
+                    config = getConfiguration(loggerContext, false, name);
+                    if (config == null) {
+                        config = getConfiguration(loggerContext, false, null);
+                    }
+                }
+            }
+            if (config != null) {
+                return config;
+            }
+            LOGGER.error("No log4j2 configuration file found. Using default configuration: logging only errors to the console.");
+            return new DefaultConfiguration();
+        }
+
+        private Configuration getConfiguration(final LoggerContext loggerContext, final String configLocationStr) {
+            ConfigurationSource source = null;
+            try {
+                source = getInputFromUri(NetUtils.toURI(configLocationStr));
+            } catch (final Exception ex) {
+                // Ignore the error and try as a String.
+                LOGGER.catching(Level.DEBUG, ex);
+            }
+            if (source == null) {
+                final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
+                source = getInputFromString(configLocationStr, loader);
+            }
+            if (source != null) {
+                for (final ConfigurationFactory factory : getFactories()) {
+                    final String[] types = factory.getSupportedTypes();
+                    if (types != null) {
+                        for (final String type : types) {
+                            if (type.equals(ALL_TYPES) || configLocationStr.endsWith(type)) {
+                                final Configuration config = factory.getConfiguration(loggerContext, source);
+                                if (config != null) {
+                                    return config;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            return null;
+        }
+
+        private Configuration getConfiguration(final LoggerContext loggerContext, final boolean isTest, final String name) {
+            final boolean named = Strings.isNotEmpty(name);
+            final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
+            for (final ConfigurationFactory factory : getFactories()) {
+                String configName;
+                final String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX;
+                final String [] types = factory.getSupportedTypes();
+                if (types == null) {
+                    continue;
+                }
+
+                for (final String suffix : types) {
+                    if (suffix.equals(ALL_TYPES)) {
+                        continue;
+                    }
+                    configName = named ? prefix + name + suffix : prefix + suffix;
+
+                    final ConfigurationSource source = getInputFromResource(configName, loader);
+                    if (source != null) {
+                        return factory.getConfiguration(loggerContext, source);
+                    }
+                }
+            }
+            return null;
+        }
+
+        @Override
+        public String[] getSupportedTypes() {
+            return null;
+        }
+
+        @Override
+        public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
+            if (source != null) {
+                final String config = source.getLocation();
+                for (final ConfigurationFactory factory : getFactories()) {
+                    final String[] types = factory.getSupportedTypes();
+                    if (types != null) {
+                        for (final String type : types) {
+                            if (type.equals(ALL_TYPES) || config != null && config.endsWith(type)) {
+                                final Configuration c = factory.getConfiguration(loggerContext, source);
+                                if (c != null) {
+                                    LOGGER.debug("Loaded configuration from {}", source);
+                                    return c;
+                                }
+                                LOGGER.error("Cannot determine the ConfigurationFactory to use for {}", config);
+                                return null;
+                            }
+                        }
+                    }
+                }
+            }
+            LOGGER.error("Cannot process configuration, input source is null");
+            return null;
+        }
+    }
+
+    static List<ConfigurationFactory> getFactories() {
+        return factories;
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
index e186c44..cbedf7c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
@@ -43,7 +43,7 @@ public class DefaultConfiguration extends AbstractConfiguration {
      * Constructor to create the default configuration.
      */
     public DefaultConfiguration() {
-        super(ConfigurationSource.NULL_SOURCE);
+        super(null, ConfigurationSource.NULL_SOURCE);
         setToDefault();
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java
index 9b04b50..db6f779 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java
@@ -29,7 +29,7 @@ public class NullConfiguration extends AbstractConfiguration {
     public static final String NULL_NAME = "Null";
 
     public NullConfiguration() {
-        super(ConfigurationSource.NULL_SOURCE);
+        super(null, ConfigurationSource.NULL_SOURCE);
 
         setName(NULL_NAME);
         final LoggerConfig root = getRootLogger();

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java
index 1fbfa01..0cc9ae8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.config.builder.api;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
 import org.apache.logging.log4j.core.util.Builder;
@@ -391,6 +392,12 @@ public interface ConfigurationBuilder<T extends Configuration> extends Builder<T
     ConfigurationBuilder<T> setDestination(String destination);
 
     /**
+     * Sets the logger context.
+     * @param loggerContext the logger context.
+     */
+    void setLoggerContext(LoggerContext loggerContext);
+
+    /**
      * Add the properties for the root node.
      * @param key The property key.
      * @param value The property value.
@@ -405,4 +412,5 @@ public interface ConfigurationBuilder<T extends Configuration> extends Builder<T
      * @return The constructed Configuration.
      */
     T build(boolean initialize);
+
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
index 029caf2..ca35d12 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.AbstractConfiguration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
 import org.apache.logging.log4j.core.config.ConfiguratonFileWatcher;
@@ -53,8 +54,8 @@ public class BuiltConfiguration extends AbstractConfiguration {
     private Component scriptsComponent;
     private String contentType = "text";
 
-    public BuiltConfiguration(final ConfigurationSource source, final Component rootComponent) {
-        super(source);
+    public BuiltConfiguration(LoggerContext loggerContext, final ConfigurationSource source, final Component rootComponent) {
+        super(loggerContext, source);
         statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES).withStatus(getDefaultStatus());
         for (final Component component : rootComponent.getComponents()) {
             switch (component.getPluginType()) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/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 b455100..000da5d 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
@@ -21,6 +21,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationException;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
@@ -53,15 +54,15 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
     private Component scripts;
     private final Class<T> clazz;
     private ConfigurationSource source;
-    private int monitorInterval = 0;
-    private Level level = null;
-    private String verbosity = null;
-    private String destination = null;
-    private String packages = null;
-    private String shutdownFlag = null;
-    private String advertiser = null;
-
-    private String name = null;
+    private int monitorInterval;
+    private Level level;
+    private String verbosity;
+    private String destination;
+    private String packages;
+    private String shutdownFlag;
+    private String advertiser;
+    private LoggerContext loggerContext;
+    private String name;
 
     @SuppressWarnings("unchecked")
     public DefaultConfigurationBuilder() {
@@ -152,8 +153,8 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
             if (source == null) {
                 source = ConfigurationSource.NULL_SOURCE;
             }
-            final Constructor<T> constructor = clazz.getConstructor(ConfigurationSource.class, Component.class);
-            configuration = constructor.newInstance(source, root);
+            final Constructor<T> constructor = clazz.getConstructor(LoggerContext.class, ConfigurationSource.class, Component.class);
+            configuration = constructor.newInstance(loggerContext, source, root);
             configuration.setMonitorInterval(monitorInterval);
             configuration.getRootNode().getAttributes().putAll(root.getAttributes());
             if (name != null) {
@@ -400,8 +401,14 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
     }
 
     @Override
+    public void setLoggerContext(LoggerContext loggerContext) {
+        this.loggerContext = loggerContext;
+    }
+
+    @Override
     public ConfigurationBuilder<T> addRootProperty(final String key, final String value) {
         root.getAttributes().put(key, value);
         return this;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
index f272fc1..a1f1557 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
@@ -62,7 +62,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
      * @param configurations The List of Configurations to merge.
      */
     public CompositeConfiguration(final List<? extends AbstractConfiguration> configurations) {
-        super(ConfigurationSource.NULL_SOURCE);
+        super(null, ConfigurationSource.NULL_SOURCE);
         rootNode = configurations.get(0).getRootNode();
         this.configurations = configurations;
         final String mergeStrategyClassName = PropertiesUtil.getProperties().getStringProperty(MERGE_STRATEGY_PROPERTY,
@@ -152,7 +152,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
             if (sourceURI != null) {
                 LOGGER.warn("Unable to determine URI for configuration {}, changes to it will be ignored",
                         config.getName());
-                currentConfig = factory.getConfiguration(config.getName(), sourceURI);
+                currentConfig = factory.getConfiguration(getLoggerContext(), config.getName(), sourceURI);
                 if (currentConfig == null) {
                     LOGGER.warn("Unable to reload configuration {}, changes to it will be ignored", config.getName());
                     currentConfig = config;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
index 427fa6d..0d87268 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
@@ -26,9 +26,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.AbstractConfiguration;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
@@ -42,6 +40,10 @@ import org.apache.logging.log4j.core.config.status.StatusConfiguration;
 import org.apache.logging.log4j.core.util.FileWatcher;
 import org.apache.logging.log4j.core.util.Patterns;
 
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
 /**
  * Creates a Node hierarchy from a JSON file.
  */
@@ -51,8 +53,8 @@ public class JsonConfiguration extends AbstractConfiguration implements Reconfig
     private final List<Status> status = new ArrayList<>();
     private JsonNode root;
 
-    public JsonConfiguration(final ConfigurationSource configSource) {
-        super(configSource);
+    public JsonConfiguration(final LoggerContext loggerContext, final ConfigurationSource configSource) {
+        super(loggerContext, configSource);
         final File configFile = configSource.getFile();
         byte[] buffer;
         try {
@@ -140,7 +142,7 @@ public class JsonConfiguration extends AbstractConfiguration implements Reconfig
             if (source == null) {
                 return null;
             }
-            return new JsonConfiguration(source);
+            return new JsonConfiguration(getLoggerContext(), source);
         } catch (final IOException ex) {
             LOGGER.error("Cannot locate file {}", getConfigurationSource(), ex);
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfigurationFactory.java
index 7b45cf9..d802e0e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfigurationFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.logging.log4j.core.config.json;
 
+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.ConfigurationSource;
@@ -60,11 +61,11 @@ public class JsonConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
         if (!isActive) {
             return null;
         }
-        return new JsonConfiguration(source);
+        return new JsonConfiguration(loggerContext, source);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
index a5eaae9..b89b30c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.config.properties;
 
 import java.io.IOException;
 
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
 import org.apache.logging.log4j.core.config.Reconfigurable;
@@ -30,8 +31,9 @@ import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
  */
 public class PropertiesConfiguration extends BuiltConfiguration implements Reconfigurable {
 
-    public PropertiesConfiguration(final ConfigurationSource source, final Component root) {
-        super(source, root);
+    // ctor is called through reflection.
+    public PropertiesConfiguration(LoggerContext loggerContext, final ConfigurationSource source, final Component root) {
+        super(loggerContext, source, root);
     }
 
     @Override
@@ -42,7 +44,7 @@ public class PropertiesConfiguration extends BuiltConfiguration implements Recon
                 return null;
             }
             final PropertiesConfigurationFactory factory = new PropertiesConfigurationFactory();
-            final PropertiesConfiguration config = factory.getConfiguration(source);
+            final PropertiesConfiguration config = factory.getConfiguration(getLoggerContext(), source);
             return config == null || config.getState() != State.INITIALIZING ? null : config;
         } catch (final IOException ex) {
             LOGGER.error("Cannot locate file {}: {}", getConfigurationSource(), ex);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
index d9245ad..9a676a0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.ConfigurationException;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
 import org.apache.logging.log4j.core.config.LoggerConfig;
@@ -61,6 +62,7 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
     private static final String CONFIG_TYPE = "type";
 
     private final ConfigurationBuilder<PropertiesConfiguration> builder;
+    private LoggerContext loggerContext;
     private Properties rootProperties;
 
     public PropertiesConfigurationBuilder() {
@@ -79,7 +81,6 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
 
     @Override
     public PropertiesConfiguration build() {
-        final Map<String, String> rootProps = new HashMap<>();
         for (final String key : rootProperties.stringPropertyNames()) {
             if (!key.contains(".")) {
                 builder.addRootProperty(key, rootProperties.getProperty(key));
@@ -179,7 +180,9 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
         if (props.size() > 0) {
             builder.add(createRootLogger(props));
         }
-
+        
+        builder.setLoggerContext(loggerContext);
+        
         return builder.build(false);
     }
 
@@ -366,4 +369,13 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
         }
         return loggerBuilder;
     }
+
+    public PropertiesConfigurationBuilder setLoggerContext(LoggerContext loggerContext) {
+        this.loggerContext = loggerContext;
+        return this;
+    }
+
+    public LoggerContext getLoggerContext() {
+        return loggerContext;
+    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/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 1098e8f..2263267 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
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
 
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.ConfigurationException;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
@@ -41,14 +42,17 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
     }
 
     @Override
-    public PropertiesConfiguration getConfiguration(final ConfigurationSource source) {
+    public PropertiesConfiguration getConfiguration(LoggerContext loggerContext, final ConfigurationSource source) {
         final Properties properties = new Properties();
         try (final InputStream configStream = source.getInputStream()) {
             properties.load(configStream);
         } catch (final IOException ioe) {
             throw new ConfigurationException("Unable to load " + source.toString(), ioe);
         }
-        return new PropertiesConfigurationBuilder().setConfigurationSource(source)
-                .setRootProperties(properties).build();
+        return new PropertiesConfigurationBuilder()
+                .setConfigurationSource(source)
+                .setRootProperties(properties)
+                .setLoggerContext(loggerContext)
+                .build();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
index 799a49e..2608552 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
@@ -35,6 +35,7 @@ import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.AbstractConfiguration;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationSource;
@@ -75,8 +76,8 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu
     private boolean strict;
     private String schemaResource;
 
-    public XmlConfiguration(final ConfigurationSource configSource) {
-        super(configSource);
+    public XmlConfiguration(final LoggerContext loggerContext, final ConfigurationSource configSource) {
+        super(loggerContext, configSource);
         final File configFile = configSource.getFile();
         byte[] buffer = null;
 
@@ -255,7 +256,7 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu
             if (source == null) {
                 return null;
             }
-            final XmlConfiguration config = new XmlConfiguration(source);
+            final XmlConfiguration config = new XmlConfiguration(getLoggerContext(), source);
             return config.rootElement == null ? null : config;
         } catch (final IOException ex) {
             LOGGER.error("Cannot locate file {}", getConfigurationSource(), ex);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85c5e81a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
index 1c3e919..9de84aa 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.logging.log4j.core.config.xml;
 
+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.ConfigurationSource;
@@ -40,8 +41,8 @@ public class XmlConfigurationFactory extends ConfigurationFactory {
      * @return The Configuration.
      */
     @Override
-    public Configuration getConfiguration(final ConfigurationSource source) {
-        return new XmlConfiguration(source);
+    public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
+        return new XmlConfiguration(loggerContext, source);
     }
 
     /**


[05/42] logging-log4j2 git commit: Merge remote-tracking branch 'origin/master' into LOG4J2-1539

Posted by rp...@apache.org.
Merge remote-tracking branch 'origin/master' into LOG4J2-1539

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: d18e9c951723fe1908f4a9d3c8078ddb18d0ef03
Parents: 3f92f7c 30ea283
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Aug 23 21:13:34 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Aug 23 21:13:34 2016 -0700

----------------------------------------------------------------------
 .../logging/log4j/core/LoggerContext.java       | 26 ++++++++-----
 .../log4j/core/appender/FileAppender.java       |  4 +-
 .../core/appender/RollingFileAppender.java      |  4 +-
 .../core/config/AbstractConfiguration.java      | 27 ++++++-------
 .../log4j/core/config/AppenderControl.java      |  3 +-
 .../logging/log4j/core/config/LoggerConfig.java | 36 +-----------------
 .../config/plugins/PluginBuilderFactory.java    |  1 +
 .../config/plugins/PluginConfiguration.java     |  1 +
 .../core/config/plugins/PluginFactory.java      |  2 +-
 .../log4j/core/config/plugins/PluginNode.java   |  1 +
 .../core/config/plugins/util/PluginBuilder.java |  2 -
 .../config/plugins/util/PluginRegistry.java     |  1 -
 .../core/config/plugins/util/ResolverUtil.java  |  8 +++-
 .../log4j/core/config/xml/XmlConfiguration.java | 40 ++++++++++----------
 .../apache/logging/log4j/core/jmx/Server.java   |  8 +++-
 .../log4j/core/script/ScriptManager.java        |  1 -
 .../apache/logging/log4j/core/util/Assert.java  | 38 -------------------
 .../logging/log4j/core/util/Constants.java      | 11 ------
 .../core/appender/OutputStreamAppenderTest.java |  2 +-
 .../rolling/RollingFileAppenderAccessTest.java  |  2 +-
 .../config/plugins/util/ResolverUtilTest.java   | 20 ++++++++++
 .../org/apache/logging/log4j/web/WebLookup.java |  8 ----
 src/changes/changes.xml                         | 30 +++++++++++++++
 23 files changed, 126 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d18e9c95/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d18e9c95/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
----------------------------------------------------------------------


[41/42] logging-log4j2 git commit: LOG4J2-1010 DynamicThresholdFilter should get context data from the configured ContextDataInjector, not hard-coded from ThreadContext

Posted by rp...@apache.org.
LOG4J2-1010 DynamicThresholdFilter should get context data from the configured ContextDataInjector, not hard-coded from ThreadContext


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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 07f3fad7f2c461ac583be9bb233beeae4bd394d2
Parents: 498bdb5
Author: rpopma <rp...@apache.org>
Authored: Sat Aug 27 15:52:12 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Aug 27 15:52:12 2016 +0900

----------------------------------------------------------------------
 .../core/filter/DynamicThresholdFilter.java     | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/07f3fad7/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
index eaa999c..d6146d7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
@@ -169,28 +169,28 @@ public final class DynamicThresholdFilter extends AbstractFilter {
     @Override
     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
             final Object p0) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
     @Override
     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
             final Object p0, final Object p1) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
     @Override
     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
             final Object p0, final Object p1, final Object p2) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
     @Override
     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
             final Object p0, final Object p1, final Object p2, final Object p3) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
@@ -198,7 +198,7 @@ public final class DynamicThresholdFilter extends AbstractFilter {
     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
             final Object p0, final Object p1, final Object p2, final Object p3,
             final Object p4) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
@@ -206,7 +206,7 @@ public final class DynamicThresholdFilter extends AbstractFilter {
     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
             final Object p0, final Object p1, final Object p2, final Object p3,
             final Object p4, final Object p5) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
@@ -214,7 +214,7 @@ public final class DynamicThresholdFilter extends AbstractFilter {
     public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
             final Object p0, final Object p1, final Object p2, final Object p3,
             final Object p4, final Object p5, final Object p6) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
@@ -223,7 +223,7 @@ public final class DynamicThresholdFilter extends AbstractFilter {
             final Object p0, final Object p1, final Object p2, final Object p3,
             final Object p4, final Object p5, final Object p6,
             final Object p7) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
@@ -232,7 +232,7 @@ public final class DynamicThresholdFilter extends AbstractFilter {
             final Object p0, final Object p1, final Object p2, final Object p3,
             final Object p4, final Object p5, final Object p6,
             final Object p7, final Object p8) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 
@@ -241,7 +241,7 @@ public final class DynamicThresholdFilter extends AbstractFilter {
             final Object p0, final Object p1, final Object p2, final Object p3,
             final Object p4, final Object p5, final Object p6,
             final Object p7, final Object p8, final Object p9) {
-        return filter(level, ThreadContext.getContext());
+        return filter(level, currentContextData());
 
     }
 


[42/42] logging-log4j2 git commit: Merge branch 'LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure' into LOG4J2-1349-gcfree-threadcontext

Posted by rp...@apache.org.
Merge branch 'LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure' into LOG4J2-1349-gcfree-threadcontext


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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 3832ad9b31d3549f443bd2bd4b76c400cd47a8e4
Parents: 37d47a6 07f3fad
Author: rpopma <rp...@apache.org>
Authored: Sat Aug 27 15:55:00 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Aug 27 15:55:00 2016 +0900

----------------------------------------------------------------------
 .../config/Log4j1ConfigurationFactory.java      |    9 +-
 .../log4j/config/Log4j1ConfigurationParser.java |  210 ++--
 .../apache/log4j/BasicConfigurationFactory.java |   13 +-
 .../config/Log4j1ConfigurationFactoryTest.java  |   29 +-
 ...g4j-console-EnhancedPatternLayout.properties |    1 -
 .../log4j-console-HtmlLayout.properties         |    1 -
 .../log4j-console-PatternLayout.properties      |    1 -
 .../log4j-console-SimpleLayout.properties       |    1 -
 .../log4j-console-TTCCLayout.properties         |    1 -
 .../log4j-console-XmlLayout.properties          |    1 -
 .../log4j-file-SimpleLayout.properties          |   17 +
 .../logging/log4j/core/AbstractLifeCycle.java   |    8 +
 .../apache/logging/log4j/core/LifeCycle.java    |   13 +
 .../logging/log4j/core/LoggerContext.java       |  113 +-
 .../log4j/core/appender/AbstractManager.java    |   17 +-
 .../core/appender/ConfigurationFactoryData.java |   50 +
 .../log4j/core/appender/ConsoleAppender.java    |    4 -
 .../log4j/core/appender/FileAppender.java       |   12 +-
 .../log4j/core/appender/FileManager.java        |   30 +-
 .../core/appender/OutputStreamManager.java      |   12 +-
 .../core/appender/RandomAccessFileAppender.java |    2 +-
 .../core/appender/RandomAccessFileManager.java  |   27 +-
 .../core/appender/RollingFileAppender.java      |   16 +-
 .../RollingRandomAccessFileAppender.java        |    2 +-
 .../log4j/core/appender/WriterManager.java      |    2 +-
 .../appender/db/AbstractDatabaseManager.java    |    2 +-
 .../log4j/core/appender/mom/JmsManager.java     |    2 +-
 .../core/appender/mom/jeromq/JeroMqManager.java |    2 +-
 .../core/appender/mom/kafka/KafkaAppender.java  |    7 +-
 .../core/appender/mom/kafka/KafkaManager.java   |   22 +-
 .../appender/rolling/RollingFileManager.java    |   44 +-
 .../rolling/RollingRandomAccessFileManager.java |   32 +-
 .../core/config/AbstractConfiguration.java      |   15 +-
 .../log4j/core/config/Configuration.java        |    8 +
 .../log4j/core/config/ConfigurationFactory.java | 1113 +++++++++---------
 .../core/config/ConfigurationScheduler.java     |   10 +-
 .../core/config/ConfiguratonFileWatcher.java    |   10 +-
 .../logging/log4j/core/config/Configurator.java |   36 +-
 .../log4j/core/config/DefaultConfiguration.java |    2 +-
 .../log4j/core/config/NullConfiguration.java    |    2 +-
 .../builder/api/ConfigurationBuilder.java       |    8 +
 .../config/builder/impl/BuiltConfiguration.java |    5 +-
 .../impl/DefaultConfigurationBuilder.java       |   29 +-
 .../composite/CompositeConfiguration.java       |    4 +-
 .../core/config/json/JsonConfiguration.java     |   14 +-
 .../config/json/JsonConfigurationFactory.java   |    5 +-
 .../core/config/plugins/util/ResolverUtil.java  |   11 +-
 .../properties/PropertiesConfiguration.java     |    8 +-
 .../PropertiesConfigurationBuilder.java         |   16 +-
 .../PropertiesConfigurationFactory.java         |   10 +-
 .../log4j/core/config/xml/XmlConfiguration.java |    7 +-
 .../config/xml/XmlConfigurationFactory.java     |    6 +-
 .../core/config/yaml/YamlConfiguration.java     |    7 +-
 .../config/yaml/YamlConfigurationFactory.java   |    5 +-
 .../core/filter/DynamicThresholdFilter.java     |   84 +-
 .../log4j/core/impl/Log4jContextFactory.java    |    6 +-
 .../log4j/core/jmx/LoggerContextAdmin.java      |    4 +-
 .../apache/logging/log4j/core/jmx/Server.java   |    6 +-
 .../logging/log4j/core/net/JndiManager.java     |    2 +-
 .../logging/log4j/core/net/SmtpManager.java     |    2 +-
 .../core/net/server/AbstractSocketServer.java   |    7 +-
 .../log4j/core/net/server/JmsServer.java        |    7 +
 .../util/DefaultShutdownCallbackRegistry.java   |    7 +
 .../log4j/core/util/Log4jThreadFactory.java     |   11 +
 .../log4j/core/BasicConfigurationFactory.java   |    6 +-
 .../appender/RandomAccessFileManagerTest.java   |   18 +-
 .../rolling/OnStartupTriggeringPolicyTest.java  |    2 +-
 .../RandomRollingAppenderOnStartupTest.java     |    2 +-
 .../RollingAppenderCronOnceADayTest.java        |  125 ++
 .../rolling/RollingAppenderCronTest.java        |    2 +-
 .../RollingAppenderCustomDeleteActionTest.java  |    2 +-
 ...lingAppenderDeleteAccumulatedCount1Test.java |    2 +-
 ...lingAppenderDeleteAccumulatedCount2Test.java |    2 +-
 ...ollingAppenderDeleteAccumulatedSizeTest.java |    2 +-
 .../RollingAppenderDeleteMaxDepthTest.java      |    2 +-
 .../RollingAppenderDeleteNestedTest.java        |    2 +-
 .../RollingAppenderDeleteScriptFri13thTest.java |    2 +-
 .../RollingAppenderDeleteScriptTest.java        |    2 +-
 ...ollingAppenderNoUnconditionalDeleteTest.java |    2 +-
 .../rolling/RollingAppenderOnStartupTest.java   |    2 +-
 .../rolling/RollingAppenderSizeTest.java        |    2 +-
 .../rolling/RollingAppenderTimeAndSizeTest.java |    4 +-
 .../rolling/RollingAppenderTimeTest.java        |    2 +-
 ...RandomAccessFileManagerHeaderFooterTest.java |    3 +-
 .../RollingRandomAccessFileManagerTest.java     |   24 +-
 .../log4j/core/config/ConfigurationTest.java    |    6 +
 .../builder/CustomConfigurationFactory.java     |   11 +-
 .../plugins/util/PluginManagerPackagesTest.java |    2 +-
 .../util/ResolverUtilCustomProtocolTest.java    |  208 ++++
 .../config/plugins/util/ResolverUtilTest.java   |  146 ++-
 .../core/filter/DynamicThresholdFilterTest.java |   17 +
 .../core/layout/CsvParameterLayoutTest.java     |   59 +-
 .../logging/log4j/junit/LoggerContextRule.java  |   25 +-
 .../junit/URLStreamHandlerFactoryRule.java      |   96 ++
 .../resources/log4j-rolling-cron-once-a-day.xml |   47 +
 .../src/test/resources/log4j-rolling-cron.xml   |    2 +-
 .../src/test/resources/log4j-rolling-cron2.xml  |    2 +-
 .../flume/appender/AbstractFlumeManager.java    |    2 +-
 .../configuration/CustomConfiguration.java      |   13 +-
 .../CustomConfigurationFactory.java             |   12 +-
 pom.xml                                         |    2 +-
 src/changes/changes.xml                         |   62 +-
 src/site/xdoc/manual/customconfig.xml           |   10 +-
 src/site/xdoc/manual/extending.xml              |    8 +-
 104 files changed, 2099 insertions(+), 1011 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3832ad9b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
----------------------------------------------------------------------
diff --cc log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
index 8e5d9f5,d6146d7..3d97f2e
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
@@@ -34,13 -35,12 +34,13 @@@ import org.apache.logging.log4j.core.co
  import org.apache.logging.log4j.core.impl.ContextDataFactory;
  import org.apache.logging.log4j.core.impl.ContextDataInjector;
  import org.apache.logging.log4j.core.impl.ContextDataInjectorFactory;
 -import org.apache.logging.log4j.core.impl.MutableContextData;
  import org.apache.logging.log4j.core.util.KeyValuePair;
  import org.apache.logging.log4j.message.Message;
 +import org.apache.logging.log4j.spi.ContextData;
 +import org.apache.logging.log4j.spi.MutableContextData;
  
  /**
-  * Compare against a log level that is associated with a context value. By default the context is the
+  * Compares against a log level that is associated with a context value. By default the context is the
   * {@link ThreadContext}, but users may {@linkplain ContextDataInjectorFactory configure} a custom
   * {@link ContextDataInjector} which obtains context data from some other source.
   */