You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2015/08/31 06:37:22 UTC

[01/12] logging-log4j2 git commit: Rename Configurator.setChildren() to setAllLevels().

Repository: logging-log4j2
Updated Branches:
  refs/heads/LOG4J2-952 7e73c9614 -> 997f808ec


Rename Configurator.setChildren() to setAllLevels().

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

Branch: refs/heads/LOG4J2-952
Commit: bc2f21a1a27e3b9ccd343742140106c30ebeb19b
Parents: 920ebf7
Author: ggregory <gg...@apache.org>
Authored: Thu Aug 27 12:27:34 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Thu Aug 27 12:27:34 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/core/config/Configurator.java  | 2 +-
 .../src/test/java/org/apache/logging/log4j/core/LoggerTest.java  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bc2f21a1/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 cb3d4ef..d1d83be 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
@@ -168,7 +168,7 @@ public final class Configurator {
      * @param parentLogger the parent logger
      * @param level the new level
      */
-    public static void setChildren(final String parentLogger, final Level level) {
+    public static void setAllLevels(final String parentLogger, final Level level) {
         // 1) get logger config
         // 2) if exact match, use it, if not, create it.
         // 3) set level on logger config 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bc2f21a1/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
index 81d7aa7..89f0b48 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
@@ -140,12 +140,12 @@ public class LoggerTest {
         loggerGrandchild.debug("Debug message 1 grandchild");
         final List<LogEvent> events = app.getEvents();
         assertEventCount(events, 3);
-        Configurator.setChildren(logger.getName(), Level.OFF);
+        Configurator.setAllLevels(logger.getName(), Level.OFF);
         logger.debug("Debug message 2");
         loggerChild.warn("Warn message 2 child");
         loggerGrandchild.fatal("Fatal message 2 grandchild");
         assertEventCount(events, 3);
-        Configurator.setChildren(logger.getName(), Level.DEBUG);
+        Configurator.setAllLevels(logger.getName(), Level.DEBUG);
         logger.debug("Debug message 3");
         loggerChild.warn("Trace message 3 child");
         loggerGrandchild.trace("Fatal message 3 grandchild");


[12/12] logging-log4j2 git commit: LOG4J2-952 - Convert InitialLoggerContext to LoggerContextRule

Posted by rg...@apache.org.
LOG4J2-952 - Convert InitialLoggerContext to LoggerContextRule


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

Branch: refs/heads/LOG4J2-952
Commit: 997f808ecb9679011ead74cee3252e0e73362fed
Parents: 6238c47
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Aug 30 21:37:06 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Aug 30 21:37:06 2015 -0700

----------------------------------------------------------------------
 .../core/appender/routing/PropertiesRoutingAppenderTest.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/997f808e/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java
index 2c02a92..81910fc 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.appender.routing;
 import org.apache.logging.log4j.EventLogger;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.After;
@@ -45,7 +45,7 @@ public class PropertiesRoutingAppenderTest {
     private ListAppender app;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext(CONFIG);
+    public LoggerContextRule init = new LoggerContextRule(CONFIG);
 
     @Rule
     public CleanFiles files = new CleanFiles(UNKNOWN_LOG_FILE, ALERT_LOG_FILE, ACTIVITY_LOG_FILE);


[11/12] logging-log4j2 git commit: Merge branch 'master' into LOG4J2-952

Posted by rg...@apache.org.
Merge branch 'master' into LOG4J2-952


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

Branch: refs/heads/LOG4J2-952
Commit: 6238c47e3a4f4b63f368b994983d6e319b2569d6
Parents: 7e73c96 546f4d0
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Aug 30 19:33:16 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Aug 30 19:33:16 2015 -0700

----------------------------------------------------------------------
 .../org/apache/log4j/CallerInformationTest.java | 130 +++----
 .../test/java/org/apache/log4j/LoggingTest.java |  86 ++---
 .../apache/logging/log4j/spi/LoggerContext.java |   4 +-
 .../org/apache/logging/log4j/core/Logger.java   |  12 +-
 .../logging/log4j/core/config/Configurator.java |   2 +-
 .../apache/logging/log4j/PerformanceRun.java    |   4 +-
 .../log4j/core/AppenderRefLevelJsonTest.java    |   4 +-
 .../log4j/core/AppenderRefLevelTest.java        |   4 +-
 .../log4j/core/CollectionLoggingTest.java       |   4 +-
 .../log4j/core/CustomLevelsOverrideTest.java    |   4 +-
 .../logging/log4j/core/CustomLevelsTest.java    |   4 +-
 .../log4j/core/CustomLevelsWithFiltersTest.java |   4 +-
 .../apache/logging/log4j/core/DeadlockTest.java |   4 +-
 .../logging/log4j/core/ExtendedLevelTest.java   |   4 +-
 .../logging/log4j/core/FileConfigTest.java      |   4 +-
 .../apache/logging/log4j/core/HostNameTest.java |   4 +-
 .../apache/logging/log4j/core/LevelTest.java    |   4 +-
 .../logging/log4j/core/LogEventFactoryTest.java |   4 +-
 .../logging/log4j/core/LoggerDateTest.java      |   4 +-
 .../apache/logging/log4j/core/LoggerTest.java   |   8 +-
 .../logging/log4j/core/LoggerUpdateTest.java    |   4 +-
 .../apache/logging/log4j/core/LookupTest.java   |   4 +-
 .../log4j/core/ShutdownDisabledTest.java        |   4 +-
 .../logging/log4j/core/StrictXmlConfigTest.java |   4 +-
 .../apache/logging/log4j/core/ThreadedTest.java |   4 +-
 .../log4j/core/TimestampMessageTest.java        |   4 +-
 .../apache/logging/log4j/core/XmlEvents.java    |   4 +-
 .../appender/AsyncAppenderNoLocationTest.java   |   4 +-
 .../core/appender/FailoverAppenderTest.java     |   4 +-
 .../appender/JsonCompleteFileAppenderTest.java  |   4 +-
 .../appender/RandomAccessFileAppenderTests.java |   6 +-
 .../core/appender/mom/JmsAppenderTest.java      |   4 +-
 .../appender/rewrite/RewriteAppenderTest.java   |   4 +-
 .../rolling/RollingAppenderSizeTest.java        |   6 +-
 .../rolling/RollingAppenderTimeAndSizeTest.java |   4 +-
 .../rolling/RollingAppenderTimeTest.java        |   4 +-
 ...RandomAccessFileManagerHeaderFooterTest.java |   4 +-
 .../appender/routing/RoutingAppenderTest.java   |   4 +-
 .../routing/RoutingAppenderWithJndiTest.java    |   4 +-
 .../routing/RoutingDefaultAppenderTest.java     |   4 +-
 .../log4j/core/async/AsyncRootReloadTest.java   |   4 +-
 .../core/config/AbstractLog4j2_1100Test.java    |   4 +-
 .../log4j/core/config/ConfigurationTest.java    |   6 +-
 .../core/config/CustomConfigurationTest.java    |   4 +-
 .../log4j/core/config/FileOutputTest.java       |   4 +-
 .../core/config/MissingRootLoggerTest.java      |   4 +-
 .../config/ReconfigurationDeadlockTest.java     |   4 +-
 .../logging/log4j/core/config/XIncludeTest.java |   6 +-
 .../core/config/xml/XmlLoggerPropsTest.java     |   4 +-
 .../log4j/core/filter/BurstFilterTest.java      |   4 +-
 .../log4j/core/lookup/ContextMapLookupTest.java |   4 +-
 .../core/lookup/MarkerLookupConfigTest.java     |   4 +-
 .../log4j/core/net/SocketMessageLossTest.java   |   4 +-
 .../log4j/core/net/SocketReconnectTest.java     |   4 +-
 .../logging/log4j/core/net/SocketTest.java      |   4 +-
 .../core/pattern/CallerInformationTest.java     |   4 +-
 .../core/pattern/ExtendedThrowableTest.java     |   4 +-
 .../log4j/core/pattern/NoConsoleNoAnsiTest.java |   4 +-
 .../core/pattern/RegexReplacementTest.java      |   4 +-
 .../log4j/core/pattern/RootThrowableTest.java   |   4 +-
 .../log4j/core/pattern/StyleConverterTest.java  |   4 +-
 .../log4j/core/pattern/ThrowableTest.java       |   4 +-
 .../core/util/ShutdownCallbackRegistryTest.java |   4 +-
 .../log4j/junit/InitialLoggerContext.java       | 144 --------
 .../logging/log4j/junit/LoggerContextRule.java  | 144 ++++++++
 .../log4j/test/appender/ListAppender.java       |   4 +-
 .../logging/log4j/io/AbstractStreamTest.java    | 118 +++---
 .../log4j/io/IoBuilderCallerInfoTesting.java    | 110 +++---
 .../apache/logging/log4j/io/IoBuilderTest.java  | 102 +++---
 .../log4j/io/LoggerPrintWriterJdbcH2Test.java   | 190 +++++-----
 .../log4j/jcl/CallerInformationTest.java        | 134 +++----
 .../apache/logging/log4j/jcl/LoggerTest.java    | 130 +++----
 .../apache/logging/log4j/jul/CoreLogger.java    |   2 +-
 .../log4j/jul/DefaultLevelConverter.java        |   3 +
 .../logging/log4j/jul/LevelConverter.java       |   2 +-
 .../logging/log4j/jul/LevelTranslator.java      |   4 +-
 .../log4j/jul/CallerInformationTest.java        | 156 ++++----
 .../logging/log4j/jul/CoreLoggerTest.java       |  20 +
 .../log4j/jul/DefaultLevelConverterTest.java    |  31 ++
 .../log4j/nosql/appender/MongoDbTest.java       |  74 ++--
 .../logging/slf4j/CallerInformationTest.java    | 134 +++----
 .../org/apache/logging/slf4j/LoggerTest.java    | 364 +++++++++----------
 .../org/apache/logging/slf4j/OptionalTest.java  | 138 +++----
 .../org/apache/logging/slf4j/SerializeTest.java |  94 ++---
 src/changes/changes.xml                         |   6 +
 85 files changed, 1324 insertions(+), 1258 deletions(-)
----------------------------------------------------------------------


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


[10/12] logging-log4j2 git commit: Rename internal JUnit extension class InitialLoggerContext to LoggerContextRule.

Posted by rg...@apache.org.
Rename internal JUnit extension class InitialLoggerContext to
LoggerContextRule.

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

Branch: refs/heads/LOG4J2-952
Commit: 546f4d0439c3cc14c6e78ad5b81c84790ee94da7
Parents: b4f73bc
Author: ggregory <gg...@apache.org>
Authored: Sat Aug 29 13:57:52 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Sat Aug 29 13:57:52 2015 -0700

----------------------------------------------------------------------
 .../org/apache/log4j/CallerInformationTest.java | 130 +++----
 .../test/java/org/apache/log4j/LoggingTest.java |  86 ++---
 .../apache/logging/log4j/PerformanceRun.java    |   4 +-
 .../log4j/core/AppenderRefLevelJsonTest.java    |   4 +-
 .../log4j/core/AppenderRefLevelTest.java        |   4 +-
 .../log4j/core/CollectionLoggingTest.java       |   4 +-
 .../log4j/core/CustomLevelsOverrideTest.java    |   4 +-
 .../logging/log4j/core/CustomLevelsTest.java    |   4 +-
 .../log4j/core/CustomLevelsWithFiltersTest.java |   4 +-
 .../apache/logging/log4j/core/DeadlockTest.java |   4 +-
 .../logging/log4j/core/ExtendedLevelTest.java   |   4 +-
 .../logging/log4j/core/FileConfigTest.java      |   4 +-
 .../apache/logging/log4j/core/HostNameTest.java |   4 +-
 .../apache/logging/log4j/core/LevelTest.java    |   4 +-
 .../logging/log4j/core/LogEventFactoryTest.java |   4 +-
 .../logging/log4j/core/LoggerDateTest.java      |   4 +-
 .../apache/logging/log4j/core/LoggerTest.java   |   4 +-
 .../logging/log4j/core/LoggerUpdateTest.java    |   4 +-
 .../apache/logging/log4j/core/LookupTest.java   |   4 +-
 .../log4j/core/ShutdownDisabledTest.java        |   4 +-
 .../logging/log4j/core/StrictXmlConfigTest.java |   4 +-
 .../apache/logging/log4j/core/ThreadedTest.java |   4 +-
 .../log4j/core/TimestampMessageTest.java        |   4 +-
 .../apache/logging/log4j/core/XmlEvents.java    |   4 +-
 .../appender/AsyncAppenderNoLocationTest.java   |   4 +-
 .../core/appender/FailoverAppenderTest.java     |   4 +-
 .../appender/JsonCompleteFileAppenderTest.java  |   4 +-
 .../appender/RandomAccessFileAppenderTests.java |   6 +-
 .../core/appender/mom/JmsAppenderTest.java      |   4 +-
 .../appender/rewrite/RewriteAppenderTest.java   |   4 +-
 .../rolling/RollingAppenderSizeTest.java        |   6 +-
 .../rolling/RollingAppenderTimeAndSizeTest.java |   4 +-
 .../rolling/RollingAppenderTimeTest.java        |   4 +-
 ...RandomAccessFileManagerHeaderFooterTest.java |   4 +-
 .../appender/routing/RoutingAppenderTest.java   |   4 +-
 .../routing/RoutingAppenderWithJndiTest.java    |   4 +-
 .../routing/RoutingDefaultAppenderTest.java     |   4 +-
 .../log4j/core/async/AsyncRootReloadTest.java   |   4 +-
 .../core/config/AbstractLog4j2_1100Test.java    |   4 +-
 .../log4j/core/config/ConfigurationTest.java    |   6 +-
 .../core/config/CustomConfigurationTest.java    |   4 +-
 .../log4j/core/config/FileOutputTest.java       |   4 +-
 .../core/config/MissingRootLoggerTest.java      |   4 +-
 .../config/ReconfigurationDeadlockTest.java     |   4 +-
 .../logging/log4j/core/config/XIncludeTest.java |   6 +-
 .../core/config/xml/XmlLoggerPropsTest.java     |   4 +-
 .../log4j/core/filter/BurstFilterTest.java      |   4 +-
 .../log4j/core/lookup/ContextMapLookupTest.java |   4 +-
 .../core/lookup/MarkerLookupConfigTest.java     |   4 +-
 .../log4j/core/net/SocketMessageLossTest.java   |   4 +-
 .../log4j/core/net/SocketReconnectTest.java     |   4 +-
 .../logging/log4j/core/net/SocketTest.java      |   4 +-
 .../core/pattern/CallerInformationTest.java     |   4 +-
 .../core/pattern/ExtendedThrowableTest.java     |   4 +-
 .../log4j/core/pattern/NoConsoleNoAnsiTest.java |   4 +-
 .../core/pattern/RegexReplacementTest.java      |   4 +-
 .../log4j/core/pattern/RootThrowableTest.java   |   4 +-
 .../log4j/core/pattern/StyleConverterTest.java  |   4 +-
 .../log4j/core/pattern/ThrowableTest.java       |   4 +-
 .../core/util/ShutdownCallbackRegistryTest.java |   4 +-
 .../log4j/junit/InitialLoggerContext.java       | 144 --------
 .../logging/log4j/junit/LoggerContextRule.java  | 144 ++++++++
 .../log4j/test/appender/ListAppender.java       |   4 +-
 .../logging/log4j/io/AbstractStreamTest.java    | 118 +++---
 .../log4j/io/IoBuilderCallerInfoTesting.java    | 110 +++---
 .../apache/logging/log4j/io/IoBuilderTest.java  | 102 +++---
 .../log4j/io/LoggerPrintWriterJdbcH2Test.java   | 190 +++++-----
 .../log4j/jcl/CallerInformationTest.java        | 134 +++----
 .../apache/logging/log4j/jcl/LoggerTest.java    | 130 +++----
 .../log4j/jul/CallerInformationTest.java        | 156 ++++----
 .../log4j/nosql/appender/MongoDbTest.java       |  74 ++--
 .../logging/slf4j/CallerInformationTest.java    | 134 +++----
 .../org/apache/logging/slf4j/LoggerTest.java    | 364 +++++++++----------
 .../org/apache/logging/slf4j/OptionalTest.java  | 138 +++----
 .../org/apache/logging/slf4j/SerializeTest.java |  94 ++---
 75 files changed, 1246 insertions(+), 1246 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
index 013bd35..80cea0a 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
@@ -1,65 +1,65 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.log4j;
-
-import java.util.List;
-
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class CallerInformationTest {
-
-    // config from log4j-core test-jar
-    private static final String CONFIG = "log4j2-calling-class.xml";
-
-    @Rule
-    public final InitialLoggerContext ctx = new InitialLoggerContext(CONFIG);
-
-    @Test
-    public void testClassLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Class").clear();
-        final Logger logger = Logger.getLogger("ClassLogger");
-        logger.info("Ignored message contents.");
-        logger.warn("Verifying the caller class is still correct.");
-        logger.error("Hopefully nobody breaks me!");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 3, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
-        }
-    }
-
-    @Test
-    public void testMethodLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Method").clear();
-        final Logger logger = Logger.getLogger("MethodLogger");
-        logger.info("More messages.");
-        logger.warn("CATASTROPHE INCOMING!");
-        logger.error("ZOMBIES!!!");
-        logger.warn("brains~~~");
-        logger.info("Itchy. Tasty.");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 5, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.log4j;
+
+import java.util.List;
+
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class CallerInformationTest {
+
+    // config from log4j-core test-jar
+    private static final String CONFIG = "log4j2-calling-class.xml";
+
+    @Rule
+    public final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
+
+    @Test
+    public void testClassLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Class").clear();
+        final Logger logger = Logger.getLogger("ClassLogger");
+        logger.info("Ignored message contents.");
+        logger.warn("Verifying the caller class is still correct.");
+        logger.error("Hopefully nobody breaks me!");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 3, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
+        }
+    }
+
+    @Test
+    public void testMethodLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Method").clear();
+        final Logger logger = Logger.getLogger("MethodLogger");
+        logger.info("More messages.");
+        logger.warn("CATASTROPHE INCOMING!");
+        logger.error("ZOMBIES!!!");
+        logger.warn("brains~~~");
+        logger.info("Itchy. Tasty.");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 5, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
index d10000d..a30dd88 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
@@ -1,43 +1,43 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.log4j;
-
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class LoggingTest {
-
-    private static final String CONFIG = "log4j2-config.xml";
-
-    @ClassRule
-    public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG);
-
-    @Test
-    public void testParent() {
-        final Logger logger = Logger.getLogger("org.apache.test.logging.Test");
-        final Category parent = logger.getParent();
-        assertNotNull("No parent Logger", parent);
-        assertEquals("Incorrect parent logger", "org.apache.test.logging", parent.getName());
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.log4j;
+
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class LoggingTest {
+
+    private static final String CONFIG = "log4j2-config.xml";
+
+    @ClassRule
+    public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG);
+
+    @Test
+    public void testParent() {
+        final Logger logger = Logger.getLogger("org.apache.test.logging.Test");
+        final Category parent = logger.getParent();
+        assertNotNull("No parent Logger", parent);
+        assertEquals("Incorrect parent logger", "org.apache.test.logging", parent.getName());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java b/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java
index 76e191e..64f0e35 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java
@@ -25,7 +25,7 @@ import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 
 import org.apache.logging.log4j.categories.PerformanceTests;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -43,7 +43,7 @@ public class PerformanceRun {
     private static final String CONFIG = "log4j2-perf.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     private final Logger logger = context.getLogger(PerformanceRun.class.getName());
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java
index 119b179..a6c7697 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelJsonTest.java
@@ -18,7 +18,7 @@ package org.apache.logging.log4j.core;
 
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -37,7 +37,7 @@ public class AppenderRefLevelJsonTest {
     private ListAppender app2;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     org.apache.logging.log4j.Logger logger1 = context.getLogger("org.apache.logging.log4j.test1");
     org.apache.logging.log4j.Logger logger2 = context.getLogger("org.apache.logging.log4j.test2");

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java
index e2f7596..d59c1a0 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/AppenderRefLevelTest.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -38,7 +38,7 @@ public class AppenderRefLevelTest {
     private ListAppender app2;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     org.apache.logging.log4j.Logger logger1 = context.getLogger("org.apache.logging.log4j.test1");
     org.apache.logging.log4j.Logger logger2 = context.getLogger("org.apache.logging.log4j.test2");

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/CollectionLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/CollectionLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/CollectionLoggingTest.java
index d286b9c..505bf3f 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/CollectionLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/CollectionLoggingTest.java
@@ -23,7 +23,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.MapMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
@@ -39,7 +39,7 @@ public class CollectionLoggingTest {
     private ListAppender app;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void before() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsOverrideTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsOverrideTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsOverrideTest.java
index bca0482..628d73f 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsOverrideTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsOverrideTest.java
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertThat;
 import java.util.List;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -39,7 +39,7 @@ public class CustomLevelsOverrideTest {
     private static final String CONFIG = "log4j-customLevels.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     private ListAppender listAppender;
     private Level warnLevel;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
index 4c61167..7bb7297 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertThat;
 import java.util.List;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -38,7 +38,7 @@ public class CustomLevelsTest {
     private static final String CONFIG = "log4j-customLevels.xml";
     
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
     
     private ListAppender listAppender;
     private Level diagLevel;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsWithFiltersTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsWithFiltersTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsWithFiltersTest.java
index d7f62ba..bdb2522 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsWithFiltersTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsWithFiltersTest.java
@@ -26,7 +26,7 @@ import org.apache.logging.log4j.core.appender.FileAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.filter.CompositeFilter;
 import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -40,7 +40,7 @@ public class CustomLevelsWithFiltersTest {
     private static final String CONFIG = "log4j-customLevelsWithFilters.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     private Level infom1Level;
     private Level infop1Level;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
index 5e7023d..4deda12 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.logging.log4j.core;
 
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.ClassRule;
 import org.junit.Test;
 
@@ -27,7 +27,7 @@ public class DeadlockTest {
 
     private static final String CONFIG = "log4j-deadlock.xml";
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Test
     public void deadlockOnReconfigure() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
index 4eaba80..8126197 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core;
 import java.util.List;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.ExtendedLevels;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
@@ -39,7 +39,7 @@ public class ExtendedLevelTest {
     private ListAppender list2;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void before() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java
index 33a0ba6..1b9face 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java
@@ -23,7 +23,7 @@ import java.io.File;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -36,7 +36,7 @@ public class FileConfigTest {
     private static final String CONFIG = "target/test-classes/log4j-test2.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     private final org.apache.logging.log4j.Logger logger = context.getLogger("LoggerTest");
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/HostNameTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/HostNameTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/HostNameTest.java
index e303da6..ca7b99e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/HostNameTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/HostNameTest.java
@@ -21,7 +21,7 @@ import java.util.List;
 import org.apache.logging.log4j.core.appender.RollingFileAppender;
 import org.apache.logging.log4j.core.util.Constants;
 import org.apache.logging.log4j.core.util.NetUtils;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -41,7 +41,7 @@ public class HostNameTest {
     private RollingFileAppender hostFile;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void before() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java
index ee0730c..a21c90c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java
@@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.ObjectMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
@@ -48,7 +48,7 @@ public class LevelTest {
     private ListAppender listFatal;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void before() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventFactoryTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventFactoryTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventFactoryTest.java
index c2898c4..d2e971c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventFactoryTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventFactoryTest.java
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.impl.LogEventFactory;
 import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
@@ -48,7 +48,7 @@ import org.junit.runners.model.Statement;
 public class LogEventFactoryTest {
 
     private static final String CONFIG = "log4j2-config.xml";
-    private static final InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    private static final LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     private ListAppender app;
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerDateTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerDateTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerDateTest.java
index a3912f7..78a2320 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerDateTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerDateTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core;
 import java.util.Calendar;
 
 import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -35,7 +35,7 @@ public class LoggerDateTest {
     private FileAppender fileApp;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void before() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
index 89f0b48..bd60eba 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
@@ -36,7 +36,7 @@ import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.Configurator;
 import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.MessageFactory;
 import org.apache.logging.log4j.message.ParameterizedMessageFactory;
 import org.apache.logging.log4j.message.StringFormatterMessageFactory;
@@ -57,7 +57,7 @@ public class LoggerTest {
     private ListAppender noThrown;
 
     @Rule
-    public InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     private void assertEventCount(final List<LogEvent> events, final int expected) {
         assertEquals("Incorrect number of events.", expected, events.size());

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerUpdateTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerUpdateTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerUpdateTest.java
index e6ff19c..fd9b0b0 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerUpdateTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerUpdateTest.java
@@ -21,7 +21,7 @@ import java.util.List;
 import org.apache.logging.log4j.*;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -38,7 +38,7 @@ public class LoggerUpdateTest {
     private ListAppender app;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void before() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/LookupTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LookupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LookupTest.java
index 35f1794..04c837a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LookupTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LookupTest.java
@@ -18,7 +18,7 @@ package org.apache.logging.log4j.core;
 
 import org.apache.logging.log4j.core.appender.ConsoleAppender;
 import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.ClassRule;
 import org.junit.Test;
 
@@ -32,7 +32,7 @@ public class LookupTest {
     private static final String CONFIG = "log4j-lookup.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Test
     public void testHostname() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/ShutdownDisabledTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/ShutdownDisabledTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/ShutdownDisabledTest.java
index f782671..5fcecd4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/ShutdownDisabledTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/ShutdownDisabledTest.java
@@ -17,7 +17,7 @@
 package org.apache.logging.log4j.core;
 
 import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.ClassRule;
 import org.junit.Test;
 
@@ -31,7 +31,7 @@ public class ShutdownDisabledTest {
     private static final String CONFIG = "log4j-test3.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Test
     public void testShutdownFlag() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/StrictXmlConfigTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/StrictXmlConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/StrictXmlConfigTest.java
index 39e6a78..edc428e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/StrictXmlConfigTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/StrictXmlConfigTest.java
@@ -22,7 +22,7 @@ import java.util.Locale;
 
 import org.apache.logging.log4j.MarkerManager;
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
@@ -40,7 +40,7 @@ public class StrictXmlConfigTest {
     private ListAppender app;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java
index 4e0adf8..3df298a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java
@@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.categories.PerformanceTests;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -43,7 +43,7 @@ public class ThreadedTest {
     private static final int LOOP_CNT = 25;
     private static final int THREADS = 4;
     private static final AtomicInteger counter = new AtomicInteger(0);
-    private static final InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    private static final LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     private final Logger logger = context.getLogger(ThreadedTest.class.getName());
     private volatile Level lvl = Level.DEBUG;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/TimestampMessageTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/TimestampMessageTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/TimestampMessageTest.java
index b295bc9..5805edb 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/TimestampMessageTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/TimestampMessageTest.java
@@ -26,7 +26,7 @@ import org.apache.logging.log4j.core.util.Clock;
 import org.apache.logging.log4j.core.util.ClockFactory;
 import org.apache.logging.log4j.core.util.ClockFactoryTest;
 import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.SimpleMessage;
 import org.apache.logging.log4j.message.TimestampMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
@@ -47,7 +47,7 @@ public class TimestampMessageTest {
     private ListAppender app;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext("log4j2-744.xml");
+    public static LoggerContextRule context = new LoggerContextRule("log4j2-744.xml");
 
     @BeforeClass
     public static void beforeClass() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/XmlEvents.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/XmlEvents.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/XmlEvents.java
index a228734..e583b89 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/XmlEvents.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/XmlEvents.java
@@ -20,7 +20,7 @@ import java.util.Locale;
 
 import org.apache.logging.log4j.EventLogger;
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -33,7 +33,7 @@ public class XmlEvents {
     private static final String CONFIG = "xml-events.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Test
     public void testEvents() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderNoLocationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderNoLocationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderNoLocationTest.java
index cbed499..32fd93d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderNoLocationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderNoLocationTest.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.After;
 import org.junit.Before;
@@ -36,7 +36,7 @@ public class AsyncAppenderNoLocationTest {
     private ListAppender app;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-asynch-no-location.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-asynch-no-location.xml");
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
index 6afab44..2cbc2df 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.FailOnceAppender;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.After;
@@ -40,7 +40,7 @@ public class FailoverAppenderTest {
     private Logger onceLogger;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-failover.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-failover.xml");
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
index 424336b..5d9b6a1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
@@ -22,7 +22,7 @@ import java.io.FileReader;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
@@ -36,7 +36,7 @@ public class JsonCompleteFileAppenderTest {
 
     private final File logFile = new File("target", "JsonCompleteFileAppenderTest.log");
 
-    private final InitialLoggerContext init = new InitialLoggerContext("JsonCompleteFileAppenderTest.xml");
+    private final LoggerContextRule init = new LoggerContextRule("JsonCompleteFileAppenderTest.xml");
     private final CleanFiles files = new CleanFiles(logFile);
 
     @Rule

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTests.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTests.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTests.java
index 42276a3..8068d59 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTests.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTests.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.hamcrest.Matcher;
 import org.junit.Rule;
 import org.junit.Test;
@@ -54,7 +54,7 @@ public class RandomAccessFileAppenderTests {
         );
     }
 
-    private final InitialLoggerContext init;
+    private final LoggerContextRule init;
     private final CleanFiles files;
 
     @Rule
@@ -64,7 +64,7 @@ public class RandomAccessFileAppenderTests {
     private final boolean locationEnabled;
 
     public RandomAccessFileAppenderTests(final String testName, final boolean locationEnabled) {
-        this.init = new InitialLoggerContext(testName + ".xml");
+        this.init = new LoggerContextRule(testName + ".xml");
         this.logFile = new File("target", testName + ".log");
         this.files = new CleanFiles(this.logFile);
         this.locationEnabled = locationEnabled;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java
index 06cf24c..9d1c65a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java
@@ -27,7 +27,7 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.util.JndiCloser;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.SimpleMessage;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -77,7 +77,7 @@ public class JmsAppenderTest {
     }
 
     @Rule
-    public InitialLoggerContext ctx = new InitialLoggerContext("JmsAppenderTest.xml");
+    public LoggerContextRule ctx = new LoggerContextRule("JmsAppenderTest.xml");
 
     @Test
     public void testAppendToQueue() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
index d0b832c..518ca87 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
@@ -23,7 +23,7 @@ import org.apache.logging.log4j.EventLogger;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.MapMessage;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.StructuredDataMessage;
@@ -43,7 +43,7 @@ public class RewriteAppenderTest {
     private ListAppender app2;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-rewrite.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-rewrite.xml");
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/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 8181b2c..18e7901 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
@@ -21,7 +21,7 @@ import java.util.Arrays;
 import java.util.Collection;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -63,11 +63,11 @@ public class RollingAppenderSizeTest {
     }
 
     @Rule
-    public InitialLoggerContext init;
+    public LoggerContextRule init;
 
     public RollingAppenderSizeTest(final String configFile, final String fileExtension) {
         this.fileExtension = fileExtension;
-        this.init = new InitialLoggerContext(configFile);
+        this.init = new LoggerContextRule(configFile);
     }
 
     @Before

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/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 456acb0..efa11d5 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
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.appender.rolling;
 import java.io.File;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -39,7 +39,7 @@ public class RollingAppenderTimeAndSizeTest {
     private static final String DIR = "target/rolling3/test";
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-rolling3.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-rolling3.xml");
 
     private Logger logger;
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/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 af951bd..52fe575 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
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.appender.rolling;
 import java.io.File;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.hamcrest.Matcher;
 import org.junit.Rule;
 import org.junit.Test;
@@ -40,7 +40,7 @@ public class RollingAppenderTimeTest {
     private static final String CONFIG = "log4j-rolling2.xml";
     private static final String DIR = "target/rolling2";
 
-    private final InitialLoggerContext ctx = new InitialLoggerContext(CONFIG);
+    private final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
 
     @Rule
     public RuleChain chain = RuleChain.outerRule(new ExternalResource() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/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 3fdac7a..f789e4a 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
@@ -23,7 +23,7 @@ import java.nio.charset.Charset;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.layout.HtmlLayout;
 import org.apache.logging.log4j.core.util.Closer;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -40,7 +40,7 @@ public class RollingRandomAccessFileManagerHeaderFooterTest {
     private static final String LOGFILE = "target/RollingRandomAccessFileAppenderHeaderFooterTest.log";
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("RollingRandomAccessFileAppenderHeaderFooterTest.xml");
+    public LoggerContextRule init = new LoggerContextRule("RollingRandomAccessFileAppenderHeaderFooterTest.xml");
 
     private Logger logger;
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
index 2fadbd6..6f1613a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
@@ -22,7 +22,7 @@ import java.util.List;
 import org.apache.logging.log4j.EventLogger;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.After;
@@ -44,7 +44,7 @@ public class RoutingAppenderTest {
     private ListAppender app;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext(CONFIG);
+    public LoggerContextRule init = new LoggerContextRule(CONFIG);
 
     @Rule
     public CleanFiles files = new CleanFiles(UNKNOWN_LOG_FILE, ALERT_LOG_FILE, ACTIVITY_LOG_FILE);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
index a4d5aca..240041b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
@@ -23,7 +23,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import org.apache.logging.log4j.EventLogger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.After;
@@ -44,7 +44,7 @@ public class RoutingAppenderWithJndiTest {
     private ListAppender listAppender2;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-routing-by-jndi.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-routing-by-jndi.xml");
 
     @Before
     public void before() throws NamingException {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
index 289ac44..948f8a9 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
@@ -22,7 +22,7 @@ import java.util.List;
 import org.apache.logging.log4j.EventLogger;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.After;
@@ -41,7 +41,7 @@ public class RoutingDefaultAppenderTest {
     private ListAppender app;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-routing3.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-routing3.xml");
 
     @Rule
     public CleanFiles files = new CleanFiles(LOG_FILE);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncRootReloadTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncRootReloadTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncRootReloadTest.java
index 03fb423..54e517a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncRootReloadTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncRootReloadTest.java
@@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.util.FileUtils;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
@@ -40,7 +40,7 @@ public class AsyncRootReloadTest {
     private static final String RESOURCE = "classpath:" + ISSUE_CONFIG;
 
     @Rule
-    public RuleChain rules = RuleChain.outerRule(new CleanFiles(LOG)).around(new InitialLoggerContext(RESOURCE));
+    public RuleChain rules = RuleChain.outerRule(new CleanFiles(LOG)).around(new LoggerContextRule(RESOURCE));
 
     @Test
     public void testLog4j2_807() throws InterruptedException, URISyntaxException {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
index 89b0904..43d91cc 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
@@ -26,14 +26,14 @@ import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
 import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
 import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
 import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Rule;
 import org.junit.Test;
 
 public abstract class AbstractLog4j2_1100Test {
 
     @Rule
-    public InitialLoggerContext context = new InitialLoggerContext(getConfigurationResource());
+    public LoggerContextRule context = new LoggerContextRule(getConfigurationResource());
 
     protected abstract String getConfigurationResource();
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/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 50ceb6a..45f5c55 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
@@ -32,7 +32,7 @@ import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.filter.ThreadContextMapFilter;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.util.Strings;
 import org.junit.Before;
 import org.junit.Rule;
@@ -63,7 +63,7 @@ public class ConfigurationTest {
     @Rule
     public TestRule rules;
 
-    private final InitialLoggerContext init;
+    private final LoggerContextRule init;
 
     private LoggerContext ctx;
 
@@ -71,7 +71,7 @@ public class ConfigurationTest {
 
     public ConfigurationTest(final String configFileName, final String logFileName) {
         this.logFileName = logFileName;
-        this.init = new InitialLoggerContext(configFileName);
+        this.init = new LoggerContextRule(configFileName);
         rules = RuleChain.outerRule(new CleanFiles(logFileName)).around(this.init);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
index 72c81a4..136686c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
@@ -27,7 +27,7 @@ import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.FileAppender;
 import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
 import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.status.StatusConsoleListener;
 import org.apache.logging.log4j.status.StatusListener;
 import org.apache.logging.log4j.status.StatusLogger;
@@ -56,7 +56,7 @@ public class CustomConfigurationTest {
     }
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-props.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-props.xml");
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
index 86efebd..4666978 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.config;
 import java.io.File;
 
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
@@ -38,7 +38,7 @@ public class FileOutputTest {
     private static final String STATUS_LOG = "target/status.log";
 
     @Rule
-    public RuleChain rules = RuleChain.outerRule(new CleanFiles(STATUS_LOG)).around(new InitialLoggerContext(CONFIG));
+    public RuleChain rules = RuleChain.outerRule(new CleanFiles(STATUS_LOG)).around(new LoggerContextRule(CONFIG));
 
     @Test
     public void testConfig() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
index 10fdacf..964f7fd 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
@@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -38,7 +38,7 @@ import static org.junit.Assert.*;
 public class MissingRootLoggerTest {
 
     @Rule
-    public InitialLoggerContext context = new InitialLoggerContext("missingRootLogger.xml");
+    public LoggerContextRule context = new LoggerContextRule("missingRootLogger.xml");
 
     @Test
     public void testMissingRootLogger() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java
index dd0f439..87c62d2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java
@@ -20,7 +20,7 @@ import java.io.File;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.ThreadDumpMessage;
 import org.junit.Rule;
 import org.junit.Test;
@@ -33,7 +33,7 @@ import static org.junit.Assert.*;
 public class ReconfigurationDeadlockTest {
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("reconfiguration-deadlock.xml");
+    public LoggerContextRule init = new LoggerContextRule("reconfiguration-deadlock.xml");
     private static final int THREAD_COUNT = 5;
     private static final boolean[] finished = new boolean[THREAD_COUNT];
     private static LoggerThread[] threads = new LoggerThread[THREAD_COUNT];

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
index 398f538..566081b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
@@ -32,7 +32,7 @@ import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.filter.ThreadContextMapFilter;
 import org.apache.logging.log4j.junit.CleanFiles;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.util.Strings;
 import org.junit.Before;
 import org.junit.Rule;
@@ -66,7 +66,7 @@ public class XIncludeTest {
     @Rule
     public TestRule rules;
 
-    private final InitialLoggerContext init;
+    private final LoggerContextRule init;
 
     private LoggerContext ctx;
 
@@ -74,7 +74,7 @@ public class XIncludeTest {
 
     public XIncludeTest(final String configFileName, final String logFileName) {
         this.logFileName = logFileName;
-        this.init = new InitialLoggerContext(configFileName);
+        this.init = new LoggerContextRule(configFileName);
         this.rules = RuleChain.outerRule(new CleanFiles(logFileName)).around(this.init);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
index 37b2c25..094defa 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -40,7 +40,7 @@ public class XmlLoggerPropsTest {
     private static final String CONFIG = "log4j-loggerprops.xml";
 
     @Rule
-    public final InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public final LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @BeforeClass
     public static void setupClass() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
index 48b5566..6ec1eb2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
@@ -20,7 +20,7 @@ package org.apache.logging.log4j.core.filter;
 import java.util.List;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -35,7 +35,7 @@ public class BurstFilterTest {
     private static final String CONFIG = "log4j-burst.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java
index 86d9b39..b80491e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java
@@ -21,7 +21,7 @@ import java.io.File;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
@@ -39,7 +39,7 @@ public class ContextMapLookupTest {
     private static final String TESTKEY = "TestKey";
     private static final String TESTVAL = "TestValue";
 
-    private final InitialLoggerContext context = new InitialLoggerContext("ContextMapLookupTest.xml");
+    private final LoggerContextRule context = new LoggerContextRule("ContextMapLookupTest.xml");
 
     @Rule
     public RuleChain chain = RuleChain.outerRule(new TestRule() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java
index 80ffdb4..62f8897 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java
@@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.junit.Assert;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -37,7 +37,7 @@ import org.junit.Test;
 public class MarkerLookupConfigTest {
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext("log4j-marker-lookup.yaml");
+    public static LoggerContextRule context = new LoggerContextRule("log4j-marker-lookup.yaml");
     public static final Marker PAYLOAD = MarkerManager.getMarker("PAYLOAD");
     private static final String PAYLOAD_LOG = "Message in payload.log";
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketMessageLossTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketMessageLossTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketMessageLossTest.java
index 472cdcd..70ab122 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketMessageLossTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketMessageLossTest.java
@@ -29,7 +29,7 @@ import java.util.concurrent.Future;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.appender.AppenderLoggingException;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.AvailablePortFinder;
 import org.junit.ClassRule;
 import org.junit.Ignore;
@@ -44,7 +44,7 @@ public class SocketMessageLossTest {
     private static final String CONFIG = "log4j-socket2.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Test
     public void testSocket() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
index fb0e545..e586f7b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
@@ -26,7 +26,7 @@ import java.util.List;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.appender.AppenderLoggingException;
 import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.AvailablePortFinder;
 import org.junit.ClassRule;
 import org.junit.Ignore;
@@ -47,7 +47,7 @@ public class SocketReconnectTest {
         "................................................................" + Constants.LINE_SEPARATOR;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Test
     public void testReconnect() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketTest.java
index 58bb56f..bcc207c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketTest.java
@@ -24,7 +24,7 @@ import java.util.concurrent.Callable;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.appender.AppenderLoggingException;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.AvailablePortFinder;
 import org.junit.ClassRule;
 import org.junit.Ignore;
@@ -39,7 +39,7 @@ public class SocketTest {
     private static final String CONFIG = "log4j-socket.xml";
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Test
     public void testConnect() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
index d8df42e..835ab4e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.pattern;
 import java.util.List;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -29,7 +29,7 @@ import static org.junit.Assert.*;
 public class CallerInformationTest {
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext("log4j2-calling-class.xml");
+    public static LoggerContextRule context = new LoggerContextRule("log4j2-calling-class.xml");
 
     @Test
     public void testClassLogger() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java
index 4e9da8a..affeae4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.pattern;
 import java.util.List;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -34,7 +34,7 @@ public class ExtendedThrowableTest {
     private ListAppender app;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext("log4j-throwablefilter.xml");
+    public static LoggerContextRule context = new LoggerContextRule("log4j-throwablefilter.xml");
 
     @Before
     public void setUp() throws Exception {


[08/12] logging-log4j2 git commit: Rename internal JUnit extension class InitialLoggerContext to LoggerContextRule.

Posted by rg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
index 587c032..e2f7908 100644
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
+++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
@@ -1,69 +1,69 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.slf4j;
-
-import java.util.List;
-
-import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class OptionalTest {
-
-    private static final String CONFIG = "log4j-test1.xml";
-
-    @ClassRule
-    public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG);
-
-    Logger logger = LoggerFactory.getLogger("EventLogger");
-    Marker marker = MarkerFactory.getMarker("EVENT");
-
-    @Test
-    public void testEventLogger() {
-        logger.info(marker, "This is a test");
-        MDC.clear();
-        verify("EventLogger", "o.a.l.s.OptionalTest This is a test" + Constants.LINE_SEPARATOR);
-    }
-
-    private void verify(final String name, final String expected) {
-        final ListAppender listApp = CTX.getListAppender(name);
-        final List<String> events = listApp.getMessages();
-        assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
-        final String actual = events.get(0);
-        assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
-        listApp.clear();
-    }
-
-    @Before
-    public void cleanup() {
-        CTX.getListAppender("List").clear();
-        CTX.getListAppender("EventLogger").clear();
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.slf4j;
+
+import java.util.List;
+
+import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class OptionalTest {
+
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @ClassRule
+    public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG);
+
+    Logger logger = LoggerFactory.getLogger("EventLogger");
+    Marker marker = MarkerFactory.getMarker("EVENT");
+
+    @Test
+    public void testEventLogger() {
+        logger.info(marker, "This is a test");
+        MDC.clear();
+        verify("EventLogger", "o.a.l.s.OptionalTest This is a test" + Constants.LINE_SEPARATOR);
+    }
+
+    private void verify(final String name, final String expected) {
+        final ListAppender listApp = CTX.getListAppender(name);
+        final List<String> events = listApp.getMessages();
+        assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
+        final String actual = events.get(0);
+        assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
+        listApp.clear();
+    }
+
+    @Before
+    public void cleanup() {
+        CTX.getListAppender("List").clear();
+        CTX.getListAppender("EventLogger").clear();
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
index 089bef3..cf93499 100644
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
+++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
@@ -1,47 +1,47 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.slf4j;
-
-import java.io.Serializable;
-
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.logging.log4j.SerializableMatchers.serializesRoundTrip;
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class SerializeTest {
-
-
-    private static final String CONFIG = "log4j-test1.xml";
-
-    @ClassRule
-    public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG);
-
-    Logger logger = LoggerFactory.getLogger("LoggerTest");
-
-    @Test
-    public void testLogger() throws Exception {
-        assertThat((Serializable) logger, serializesRoundTrip());
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.slf4j;
+
+import java.io.Serializable;
+
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.logging.log4j.SerializableMatchers.serializesRoundTrip;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class SerializeTest {
+
+
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @ClassRule
+    public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG);
+
+    Logger logger = LoggerFactory.getLogger("LoggerTest");
+
+    @Test
+    public void testLogger() throws Exception {
+        assertThat((Serializable) logger, serializesRoundTrip());
+    }
+}


[05/12] logging-log4j2 git commit: [LOG4J2-1108] NullPointerException when passing null to java.util.logging.Logger.setLevel().

Posted by rg...@apache.org.
[LOG4J2-1108] NullPointerException when passing null to
java.util.logging.Logger.setLevel().

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

Branch: refs/heads/LOG4J2-952
Commit: f14bc4867f703ff431b39e1c748b790bd063243e
Parents: de0b802
Author: ggregory <gg...@apache.org>
Authored: Fri Aug 28 12:25:20 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Aug 28 12:25:20 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/logging/log4j/core/Logger.java   | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f14bc486/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
index bf36905..91ce841 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
@@ -104,11 +104,8 @@ public class Logger extends AbstractLogger {
      * @param level The Level to use on this Logger, may be null.
      */
     public synchronized void setLevel(final Level level) {
-        if (level != null) {
-            config = new PrivateConfig(config, level);
-        } else {
-            config = new PrivateConfig(config, getParent().getLevel());
-        }
+        final Level actualLevel = level != null ? level : getParent().getLevel();
+        config = new PrivateConfig(config, actualLevel);
     }
 
     @Override


[04/12] logging-log4j2 git commit: [LOG4J2-1108] NullPointerException when passing null to java.util.logging.Logger.setLevel().

Posted by rg...@apache.org.
[LOG4J2-1108] NullPointerException when passing null to
java.util.logging.Logger.setLevel().

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

Branch: refs/heads/LOG4J2-952
Commit: de0b802aade36abe2de60106b19315e5affae164
Parents: 81e2fa4
Author: ggregory <gg...@apache.org>
Authored: Fri Aug 28 12:23:08 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Aug 28 12:23:08 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/de0b802a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
index 1e02387..bf36905 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
@@ -107,8 +107,7 @@ public class Logger extends AbstractLogger {
         if (level != null) {
             config = new PrivateConfig(config, level);
         } else {
-            // Reusing parent PC, should we make a copy instead?
-            config = getParent().config;
+            config = new PrivateConfig(config, getParent().getLevel());
         }
     }
 


[07/12] logging-log4j2 git commit: [LOG4J2-1110] org.apache.logging.log4j.jul.CoreLogger.setLevel() checks for security permission too late.

Posted by rg...@apache.org.
[LOG4J2-1110] org.apache.logging.log4j.jul.CoreLogger.setLevel() checks
for security permission too late.

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

Branch: refs/heads/LOG4J2-952
Commit: b4f73bc8f801bec8e6e2fa5123def7a2ad75c6ad
Parents: 32956ad
Author: ggregory <gg...@apache.org>
Authored: Fri Aug 28 13:46:07 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Aug 28 13:46:07 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/logging/log4j/jul/CoreLogger.java    | 2 +-
 src/changes/changes.xml                                           | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b4f73bc8/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java
index eaf7a44..df85c77 100644
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java
@@ -44,8 +44,8 @@ public class CoreLogger extends ApiLogger {
 
     @Override
     public void setLevel(final Level level) throws SecurityException {
+        super.doSetLevel(level); // checks permissions
         logger.setLevel(LevelTranslator.toLevel(level));
-        super.doSetLevel(level);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b4f73bc8/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f33e78d..76d4af9 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,9 @@
       <action issue="LOG4J2-1108" dev="ggregory" type="fix" due-to="Mikael Ståldal">
         NullPointerException when passing null to java.util.logging.Logger.setLevel().
       </action>
+      <action issue="LOG4J2-1110" dev="ggregory" type="fix">
+        org.apache.logging.log4j.jul.CoreLogger.setLevel() checks for security permission too late.
+      </action>
       <action dev="rpopma" type="remove">
         Removed experimental interface LevelLogger which got committed to master by mistake.
       </action>


[02/12] logging-log4j2 git commit: Javadoc fixes.

Posted by rg...@apache.org.
Javadoc fixes.

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

Branch: refs/heads/LOG4J2-952
Commit: 2b1b35613e66eec9658dcd471a28b214b5647174
Parents: bc2f21a
Author: ggregory <gg...@apache.org>
Authored: Thu Aug 27 14:42:08 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Thu Aug 27 14:42:08 2015 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/logging/log4j/spi/LoggerContext.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2b1b3561/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
index b7be917..5cf3eb8 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
@@ -30,14 +30,14 @@ public interface LoggerContext {
     Object getExternalContext();
 
     /**
-     * Returns a Logger.
+     * Returns an ExtendedLogger.
      * @param name The name of the Logger to return.
      * @return The logger with the specified name.
      */
     ExtendedLogger getLogger(String name);
 
     /**
-     * Returns a Logger.
+     * Returns an ExtendedLogger.
      * @param name The name of the Logger to return.
      * @param messageFactory The message factory is used only when creating a logger, subsequent use does not change
      *                       the logger but will log a warning if mismatched.


[09/12] logging-log4j2 git commit: Rename internal JUnit extension class InitialLoggerContext to LoggerContextRule.

Posted by rg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java
index bdf50d6..394fd70 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.Rule;
@@ -37,7 +37,7 @@ public class NoConsoleNoAnsiTest {
             + Constants.LINE_SEPARATOR;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j2-console-noConsoleNoAnsi.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j2-console-noConsoleNoAnsi.xml");
 
     private Logger logger;
     private ListAppender app;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
index 94fcfdf..ec526a2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.After;
 import org.junit.Before;
@@ -40,7 +40,7 @@ public class RegexReplacementTest {
     private static final String EXPECTED = "/RegexReplacementTest" + Constants.LINE_SEPARATOR;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowableTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowableTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowableTest.java
index c0f51e5..9e165a6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowableTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowableTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.pattern;
 import java.util.List;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -35,7 +35,7 @@ public class RootThrowableTest {
     private static ListAppender app;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/StyleConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/StyleConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/StyleConverterTest.java
index 0d6540c..9672367 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/StyleConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/StyleConverterTest.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.Rule;
@@ -38,7 +38,7 @@ public class StyleConverterTest {
         + Constants.LINE_SEPARATOR;
 
     @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-style.xml");
+    public LoggerContextRule init = new LoggerContextRule("log4j-style.xml");
 
     private Logger logger;
     private ListAppender app;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowableTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowableTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowableTest.java
index 108564a..80a7ed8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowableTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowableTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.pattern;
 import java.util.List;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -35,7 +35,7 @@ public class ThrowableTest {
     private static ListAppender app;
 
     @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
+    public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistryTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistryTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistryTest.java
index ff83c67..505c272 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistryTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistryTest.java
@@ -24,7 +24,7 @@ import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.impl.Log4jContextFactory;
 import org.apache.logging.log4j.core.selector.ContextSelector;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -38,7 +38,7 @@ import static org.junit.Assert.*;
 public class ShutdownCallbackRegistryTest {
 
     @Rule
-    public final InitialLoggerContext ctx = new InitialLoggerContext("ShutdownCallbackRegistryTest.xml");
+    public final LoggerContextRule ctx = new LoggerContextRule("ShutdownCallbackRegistryTest.xml");
 
     @BeforeClass
     public static void setUpClass() throws Exception {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/junit/InitialLoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/InitialLoggerContext.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/InitialLoggerContext.java
deleted file mode 100644
index b1e3ff1..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/InitialLoggerContext.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.junit;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import static org.junit.Assert.*;
-
-/**
- * JUnit {@link TestRule} for constructing a new LoggerContext using a specified configuration file.
- * If the system property {@code EBUG} is set (e.g., through the command line option {@code -DEBUG}), then the
- * StatusLogger will be set to the debug level. This allows for more debug messages as the StatusLogger will be in the
- * error level until a configuration file has been read and parsed into a tree of Nodes.
- */
-public class InitialLoggerContext implements TestRule {
-
-    private final String configLocation;
-
-    private LoggerContext context;
-
-    private String testClassName;
-
-    public InitialLoggerContext(final String configLocation) {
-        this.configLocation = configLocation;
-    }
-
-    @Override
-    public Statement apply(final Statement base, final Description description) {
-        // Hack: Using -DEBUG as a JVM param sets a property called "EBUG"... 
-        if (System.getProperties().containsKey("EBUG")) {
-            StatusLogger.getLogger().setLevel(Level.DEBUG);
-        }
-        testClassName = description.getClassName();
-        return new Statement() {
-            @Override
-            public void evaluate() throws Throwable {
-                context = Configurator.initialize(
-                    description.getDisplayName(),
-                    description.getTestClass().getClassLoader(),
-                    configLocation
-                );
-                try {
-                    base.evaluate();
-                } finally {
-                    Configurator.shutdown(context);
-                    StatusLogger.getLogger().reset();
-                }
-            }
-        };
-    }
-
-    /**
-     * Gets the current LoggerContext associated with this rule.
-     * @return the current LoggerContext.
-     */
-    public LoggerContext getContext() {
-        return context;
-    }
-
-    /**
-     * Gets a named Logger using the test class's name from this LoggerContext.
-     * @return the test class's named Logger.
-     */
-    public Logger getLogger() {
-        return context.getLogger(testClassName);
-    }
-
-    /**
-     * Gets a named Logger in this LoggerContext.
-     *
-     * @param name the name of the Logger to look up or create.
-     * @return the named Logger.
-     */
-    public Logger getLogger(final String name) {
-        return context.getLogger(name);
-    }
-
-    /**
-     * Gets the associated Configuration for the configuration file this was constructed with.
-     * @return this LoggerContext's Configuration.
-     */
-    public Configuration getConfiguration() {
-        return context.getConfiguration();
-    }
-
-    /**
-     * Gets a named Appender for this LoggerContext.
-     * @param name the name of the Appender to look up.
-     * @return the named Appender or {@code null} if it wasn't defined in the configuration.
-     */
-    public Appender getAppender(final String name) {
-        return getConfiguration().getAppenders().get(name);
-    }
-
-    /**
-     * Gets a named Appender or throws an exception for this LoggerContext.
-     * @param name the name of the Appender to look up.
-     * @return the named Appender.
-     * @throws AssertionError if the Appender doesn't exist.
-     */
-    public Appender getRequiredAppender(final String name) {
-        final Appender appender = getAppender(name);
-        assertNotNull("Appender named " + name + " was null.", appender);
-        return appender;
-    }
-
-    /**
-     * Gets a named ListAppender or throws an exception for this LoggerContext.
-     * @param name the name of the ListAppender to look up.
-     * @return the named ListAppender.
-     * @throws AssertionError if the named ListAppender doesn't exist or isn't a ListAppender.
-     */
-    public ListAppender getListAppender(final String name) {
-        final Appender appender = getAppender(name);
-        if (appender instanceof ListAppender) {
-            return (ListAppender) appender;
-        }
-        throw new AssertionError("No ListAppender named " + name + " found.");
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/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
new file mode 100644
index 0000000..65836d6
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
@@ -0,0 +1,144 @@
+/*
+ * 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 org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.Configurator;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import static org.junit.Assert.*;
+
+/**
+ * JUnit {@link TestRule} for constructing a new LoggerContext using a specified configuration file.
+ * If the system property {@code EBUG} is set (e.g., through the command line option {@code -DEBUG}), then the
+ * StatusLogger will be set to the debug level. This allows for more debug messages as the StatusLogger will be in the
+ * error level until a configuration file has been read and parsed into a tree of Nodes.
+ */
+public class LoggerContextRule implements TestRule {
+
+    private final String configLocation;
+
+    private LoggerContext context;
+
+    private String testClassName;
+
+    public LoggerContextRule(final String configLocation) {
+        this.configLocation = configLocation;
+    }
+
+    @Override
+    public Statement apply(final Statement base, final Description description) {
+        // Hack: Using -DEBUG as a JVM param sets a property called "EBUG"... 
+        if (System.getProperties().containsKey("EBUG")) {
+            StatusLogger.getLogger().setLevel(Level.DEBUG);
+        }
+        testClassName = description.getClassName();
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                context = Configurator.initialize(
+                    description.getDisplayName(),
+                    description.getTestClass().getClassLoader(),
+                    configLocation
+                );
+                try {
+                    base.evaluate();
+                } finally {
+                    Configurator.shutdown(context);
+                    StatusLogger.getLogger().reset();
+                }
+            }
+        };
+    }
+
+    /**
+     * Gets the current LoggerContext associated with this rule.
+     * @return the current LoggerContext.
+     */
+    public LoggerContext getContext() {
+        return context;
+    }
+
+    /**
+     * Gets a named Logger using the test class's name from this LoggerContext.
+     * @return the test class's named Logger.
+     */
+    public Logger getLogger() {
+        return context.getLogger(testClassName);
+    }
+
+    /**
+     * Gets a named Logger in this LoggerContext.
+     *
+     * @param name the name of the Logger to look up or create.
+     * @return the named Logger.
+     */
+    public Logger getLogger(final String name) {
+        return context.getLogger(name);
+    }
+
+    /**
+     * Gets the associated Configuration for the configuration file this was constructed with.
+     * @return this LoggerContext's Configuration.
+     */
+    public Configuration getConfiguration() {
+        return context.getConfiguration();
+    }
+
+    /**
+     * Gets a named Appender for this LoggerContext.
+     * @param name the name of the Appender to look up.
+     * @return the named Appender or {@code null} if it wasn't defined in the configuration.
+     */
+    public Appender getAppender(final String name) {
+        return getConfiguration().getAppenders().get(name);
+    }
+
+    /**
+     * Gets a named Appender or throws an exception for this LoggerContext.
+     * @param name the name of the Appender to look up.
+     * @return the named Appender.
+     * @throws AssertionError if the Appender doesn't exist.
+     */
+    public Appender getRequiredAppender(final String name) {
+        final Appender appender = getAppender(name);
+        assertNotNull("Appender named " + name + " was null.", appender);
+        return appender;
+    }
+
+    /**
+     * Gets a named ListAppender or throws an exception for this LoggerContext.
+     * @param name the name of the ListAppender to look up.
+     * @return the named ListAppender.
+     * @throws AssertionError if the named ListAppender doesn't exist or isn't a ListAppender.
+     */
+    public ListAppender getListAppender(final String name) {
+        final Appender appender = getAppender(name);
+        if (appender instanceof ListAppender) {
+            return (ListAppender) appender;
+        }
+        throw new AssertionError("No ListAppender named " + name + " found.");
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
index df2d148..05fa157 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
@@ -36,7 +36,7 @@ import org.apache.logging.log4j.core.layout.SerializedLayout;
 /**
  * This appender is primarily used for testing. Use in a real environment is discouraged as the
  * List could eventually grow to cause an OutOfMemoryError.
- * @see org.apache.logging.log4j.junit.InitialLoggerContext#getListAppender(String) ILC.getListAppender
+ * @see org.apache.logging.log4j.junit.LoggerContextRule#getListAppender(String) ILC.getListAppender
  */
 @Plugin(name = "List", category = "Core", elementType = "appender", printObject = true)
 public class ListAppender extends AbstractAppender {
@@ -178,7 +178,7 @@ public class ListAppender extends AbstractAppender {
      *
      * @param name the name of the ListAppender
      * @return the named ListAppender or {@code null} if it does not exist
-     * @see org.apache.logging.log4j.junit.InitialLoggerContext#getListAppender(String)
+     * @see org.apache.logging.log4j.junit.LoggerContextRule#getListAppender(String)
      */
     public static ListAppender getListAppender(final String name) {
         return ((ListAppender) (LoggerContext.getContext(false)).getConfiguration().getAppender(name));

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
index 31fd4b9..05502f5 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
@@ -1,59 +1,59 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.logging.log4j.io;
-
-import java.util.List;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.junit.Before;
-import org.junit.ClassRule;
-
-import static org.hamcrest.core.StringStartsWith.startsWith;
-import static org.junit.Assert.*;
-
-public abstract class AbstractStreamTest {
-
-    protected static ExtendedLogger getExtendedLogger() {
-        return ctx.getLogger("UnitTestLogger");
-    }
-    
-    protected final static String NEWLINE = System.getProperty("line.separator");
-    protected final static Level LEVEL = Level.ERROR;
-    protected final static String FIRST = "first";
-
-    protected final static String LAST = "last";
-
-    @ClassRule
-    public static InitialLoggerContext ctx = new InitialLoggerContext("log4j2-streams-unit-test.xml");
-
-    protected void assertMessages(final String... messages) {
-        final List<String> actualMsgs = ctx.getListAppender("UnitTest").getMessages();
-        assertEquals("Unexpected number of results.", messages.length, actualMsgs.size());
-        for (int i = 0; i < messages.length; i++) {
-            final String start = LEVEL.name() + ' ' + messages[i];
-            assertThat(actualMsgs.get(i), startsWith(start));
-        }
-    }
-
-    @Before
-    public void clearAppender() {
-        ctx.getListAppender("UnitTest").clear();
-    }
-}
+/*
+ * 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.io;
+
+import java.util.List;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.spi.ExtendedLogger;
+import org.junit.Before;
+import org.junit.ClassRule;
+
+import static org.hamcrest.core.StringStartsWith.startsWith;
+import static org.junit.Assert.*;
+
+public abstract class AbstractStreamTest {
+
+    protected static ExtendedLogger getExtendedLogger() {
+        return ctx.getLogger("UnitTestLogger");
+    }
+    
+    protected final static String NEWLINE = System.getProperty("line.separator");
+    protected final static Level LEVEL = Level.ERROR;
+    protected final static String FIRST = "first";
+
+    protected final static String LAST = "last";
+
+    @ClassRule
+    public static LoggerContextRule ctx = new LoggerContextRule("log4j2-streams-unit-test.xml");
+
+    protected void assertMessages(final String... messages) {
+        final List<String> actualMsgs = ctx.getListAppender("UnitTest").getMessages();
+        assertEquals("Unexpected number of results.", messages.length, actualMsgs.size());
+        for (int i = 0; i < messages.length; i++) {
+            final String start = LEVEL.name() + ' ' + messages[i];
+            assertThat(actualMsgs.get(i), startsWith(start));
+        }
+    }
+
+    @Before
+    public void clearAppender() {
+        ctx.getListAppender("UnitTest").clear();
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java
index 6db45b1..d81e173 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java
@@ -1,55 +1,55 @@
-/*
- * 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.io;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Before;
-import org.junit.ClassRule;
-
-import static org.junit.Assert.*;
-
-public class IoBuilderCallerInfoTesting {
-
-    protected static Logger getExtendedLogger() {
-        return ctx.getLogger("ClassAndMethodLogger");
-    }
-    
-    protected static Logger getLogger() {
-        return getExtendedLogger();
-    }
-    
-    protected final static Level LEVEL = Level.WARN;
-
-    @ClassRule
-    public static InitialLoggerContext ctx = new InitialLoggerContext("log4j2-streams-calling-info.xml");
-
-    public void assertMessages(final String msg, final int size, final String methodName) {
-        final ListAppender appender = ctx.getListAppender("ClassAndMethod");
-        assertEquals(msg + ".size", size, appender.getMessages().size());
-        for (final String message : appender.getMessages()) {
-            assertEquals(msg + " has incorrect caller info", this.getClass().getName() + '.' + methodName, message);
-        }
-    }
-
-    @Before
-    public void clearAppender() {
-        ctx.getListAppender("ClassAndMethod").clear();
-    }
-}
+/*
+ * 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.io;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Before;
+import org.junit.ClassRule;
+
+import static org.junit.Assert.*;
+
+public class IoBuilderCallerInfoTesting {
+
+    protected static Logger getExtendedLogger() {
+        return ctx.getLogger("ClassAndMethodLogger");
+    }
+    
+    protected static Logger getLogger() {
+        return getExtendedLogger();
+    }
+    
+    protected final static Level LEVEL = Level.WARN;
+
+    @ClassRule
+    public static LoggerContextRule ctx = new LoggerContextRule("log4j2-streams-calling-info.xml");
+
+    public void assertMessages(final String msg, final int size, final String methodName) {
+        final ListAppender appender = ctx.getListAppender("ClassAndMethod");
+        assertEquals(msg + ".size", size, appender.getMessages().size());
+        for (final String message : appender.getMessages()) {
+            assertEquals(msg + " has incorrect caller info", this.getClass().getName() + '.' + methodName, message);
+        }
+    }
+
+    @Before
+    public void clearAppender() {
+        ctx.getListAppender("ClassAndMethod").clear();
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderTest.java
index cc90e01..9205355 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderTest.java
@@ -1,51 +1,51 @@
-/*
- * 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.io;
-
-import java.io.PrintStream;
-import java.util.List;
-
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.*;
-
-public class IoBuilderTest {
-
-    @Rule
-    public InitialLoggerContext context = new InitialLoggerContext("log4j2-streams-calling-info.xml");
-
-    @Test
-    public void testNoArgBuilderCallerClassInfo() throws Exception {
-        try (final PrintStream ps = IoBuilder.forLogger().buildPrintStream()) {
-            ps.println("discarded");
-            final ListAppender app = context.getListAppender("IoBuilderTest");
-            final List<String> messages = app.getMessages();
-            assertThat(messages, not(empty()));
-            assertThat(messages, hasSize(1));
-            final String message = messages.get(0);
-            assertThat(message, startsWith(getClass().getName() + ".testNoArgBuilderCallerClassInfo"));
-            app.clear();
-        }
-    }
-}
+/*
+ * 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.io;
+
+import java.io.PrintStream;
+import java.util.List;
+
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.*;
+
+public class IoBuilderTest {
+
+    @Rule
+    public LoggerContextRule context = new LoggerContextRule("log4j2-streams-calling-info.xml");
+
+    @Test
+    public void testNoArgBuilderCallerClassInfo() throws Exception {
+        try (final PrintStream ps = IoBuilder.forLogger().buildPrintStream()) {
+            ps.println("discarded");
+            final ListAppender app = context.getListAppender("IoBuilderTest");
+            final List<String> messages = app.getMessages();
+            assertThat(messages, not(empty()));
+            assertThat(messages, hasSize(1));
+            final String message = messages.get(0);
+            assertThat(message, startsWith(getClass().getName() + ".testNoArgBuilderCallerClassInfo"));
+            app.clear();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java
index 2be2569..a7c6d0e 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java
@@ -1,95 +1,95 @@
-/*
- * 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.io;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.util.Strings;
-import org.h2.jdbcx.JdbcDataSource;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class LoggerPrintWriterJdbcH2Test {
-    @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext("log4j2-jdbc-driver-manager.xml");
-
-    private static final String H2_URL = "jdbc:h2:mem:Log4j";
-
-    private static final String PASSWORD = Strings.EMPTY;
-
-    private static final String USER_ID = "sa";
-
-    private ListAppender listAppender;
-
-    private PrintWriter createLoggerPrintWriter() {
-        return IoBuilder.forLogger(context.getLogger()).setLevel(Level.ALL).buildPrintWriter();
-    }
-
-    private ListAppender getListAppender() {
-        return listAppender;
-    }
-
-    protected Connection newConnection() throws SQLException {
-        return DriverManager.getConnection(H2_URL, USER_ID, PASSWORD);
-    }
-
-    private void setListAppender(final ListAppender listAppender) {
-        this.listAppender = listAppender;
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        this.setListAppender(context.getListAppender("List").clear());
-        Assert.assertEquals(0, this.getListAppender().getMessages().size());
-    }
-
-    @Test
-    @Ignore("DataSource#setLogWriter() has no effect in H2, it uses its own internal logging and an SLF4J bridge.")
-    public void testDataSource_setLogWriter() throws SQLException {
-        final JdbcDataSource dataSource = new JdbcDataSource();
-        dataSource.setUrl(H2_URL);
-        dataSource.setUser(USER_ID);
-        dataSource.setPassword(PASSWORD);
-        dataSource.setLogWriter(createLoggerPrintWriter());
-        // dataSource.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out)));
-        try (final Connection conn = dataSource.getConnection()) {
-            conn.prepareCall("select 1");
-        }
-        Assert.assertTrue(this.getListAppender().getMessages().size() > 0);
-    }
-
-    @Test
-    public void testDriverManager_setLogWriter() throws SQLException {
-        DriverManager.setLogWriter(createLoggerPrintWriter());
-        // DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out)));
-        try (final Connection conn = this.newConnection()) {
-            conn.rollback();
-        } finally {
-            DriverManager.setLogWriter(null);
-        }
-        Assert.assertTrue(this.getListAppender().getMessages().size() > 0);
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.io;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.apache.logging.log4j.util.Strings;
+import org.h2.jdbcx.JdbcDataSource;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class LoggerPrintWriterJdbcH2Test {
+    @ClassRule
+    public static LoggerContextRule context = new LoggerContextRule("log4j2-jdbc-driver-manager.xml");
+
+    private static final String H2_URL = "jdbc:h2:mem:Log4j";
+
+    private static final String PASSWORD = Strings.EMPTY;
+
+    private static final String USER_ID = "sa";
+
+    private ListAppender listAppender;
+
+    private PrintWriter createLoggerPrintWriter() {
+        return IoBuilder.forLogger(context.getLogger()).setLevel(Level.ALL).buildPrintWriter();
+    }
+
+    private ListAppender getListAppender() {
+        return listAppender;
+    }
+
+    protected Connection newConnection() throws SQLException {
+        return DriverManager.getConnection(H2_URL, USER_ID, PASSWORD);
+    }
+
+    private void setListAppender(final ListAppender listAppender) {
+        this.listAppender = listAppender;
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        this.setListAppender(context.getListAppender("List").clear());
+        Assert.assertEquals(0, this.getListAppender().getMessages().size());
+    }
+
+    @Test
+    @Ignore("DataSource#setLogWriter() has no effect in H2, it uses its own internal logging and an SLF4J bridge.")
+    public void testDataSource_setLogWriter() throws SQLException {
+        final JdbcDataSource dataSource = new JdbcDataSource();
+        dataSource.setUrl(H2_URL);
+        dataSource.setUser(USER_ID);
+        dataSource.setPassword(PASSWORD);
+        dataSource.setLogWriter(createLoggerPrintWriter());
+        // dataSource.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out)));
+        try (final Connection conn = dataSource.getConnection()) {
+            conn.prepareCall("select 1");
+        }
+        Assert.assertTrue(this.getListAppender().getMessages().size() > 0);
+    }
+
+    @Test
+    public void testDriverManager_setLogWriter() throws SQLException {
+        DriverManager.setLogWriter(createLoggerPrintWriter());
+        // DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out)));
+        try (final Connection conn = this.newConnection()) {
+            conn.rollback();
+        } finally {
+            DriverManager.setLogWriter(null);
+        }
+        Assert.assertTrue(this.getListAppender().getMessages().size() > 0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/CallerInformationTest.java
----------------------------------------------------------------------
diff --git a/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/CallerInformationTest.java b/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/CallerInformationTest.java
index 20ca67f..27697b7 100644
--- a/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/CallerInformationTest.java
+++ b/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/CallerInformationTest.java
@@ -1,67 +1,67 @@
-/*
- * 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.jcl;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class CallerInformationTest {
-
-    // config from log4j-core test-jar
-    private static final String CONFIG = "log4j2-calling-class.xml";
-
-    @Rule
-    public final InitialLoggerContext ctx = new InitialLoggerContext(CONFIG);
-
-    @Test
-    public void testClassLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Class").clear();
-        final Log logger = LogFactory.getLog("ClassLogger");
-        logger.info("Ignored message contents.");
-        logger.warn("Verifying the caller class is still correct.");
-        logger.error("Hopefully nobody breaks me!");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 3, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
-        }
-    }
-
-    @Test
-    public void testMethodLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Method").clear();
-        final Log logger = LogFactory.getLog("MethodLogger");
-        logger.info("More messages.");
-        logger.warn("CATASTROPHE INCOMING!");
-        logger.error("ZOMBIES!!!");
-        logger.warn("brains~~~");
-        logger.info("Itchy. Tasty.");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 5, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.jcl;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class CallerInformationTest {
+
+    // config from log4j-core test-jar
+    private static final String CONFIG = "log4j2-calling-class.xml";
+
+    @Rule
+    public final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
+
+    @Test
+    public void testClassLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Class").clear();
+        final Log logger = LogFactory.getLog("ClassLogger");
+        logger.info("Ignored message contents.");
+        logger.warn("Verifying the caller class is still correct.");
+        logger.error("Hopefully nobody breaks me!");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 3, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
+        }
+    }
+
+    @Test
+    public void testMethodLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Method").clear();
+        final Log logger = LogFactory.getLog("MethodLogger");
+        logger.info("More messages.");
+        logger.warn("CATASTROPHE INCOMING!");
+        logger.error("ZOMBIES!!!");
+        logger.warn("brains~~~");
+        logger.info("Itchy. Tasty.");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 5, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java b/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
index 6106b6f..3e73b50 100644
--- a/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
+++ b/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
@@ -1,65 +1,65 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.jcl;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class LoggerTest {
-
-    private static final String CONFIG = "log4j-test1.xml";
-
-    @Rule
-    public final InitialLoggerContext context = new InitialLoggerContext(CONFIG);
-
-    @Test
-    public void testLog() {
-        final Log logger = LogFactory.getLog("LoggerTest");
-        logger.debug("Test message");
-        verify("List", "o.a.l.l.j.LoggerTest Test message MDC{}" + Constants.LINE_SEPARATOR);
-        logger.debug("Exception: " , new NullPointerException("Test"));
-        verify("List", "o.a.l.l.j.LoggerTest Exception:  MDC{}" + Constants.LINE_SEPARATOR);
-        logger.info("Info Message");
-        verify("List", "o.a.l.l.j.LoggerTest Info Message MDC{}" + Constants.LINE_SEPARATOR);
-        logger.info("Info Message {}");
-        verify("List", "o.a.l.l.j.LoggerTest Info Message {} MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    private void verify(final String name, final String expected) {
-        final ListAppender listApp = context.getListAppender(name);
-        final List<String> events = listApp.getMessages();
-        assertThat(events, hasSize(1));
-        final String actual = events.get(0);
-        assertThat(actual, equalTo(expected));
-        listApp.clear();
-    }
-
-}
+/*
+ * 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.jcl;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class LoggerTest {
+
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @Rule
+    public final LoggerContextRule context = new LoggerContextRule(CONFIG);
+
+    @Test
+    public void testLog() {
+        final Log logger = LogFactory.getLog("LoggerTest");
+        logger.debug("Test message");
+        verify("List", "o.a.l.l.j.LoggerTest Test message MDC{}" + Constants.LINE_SEPARATOR);
+        logger.debug("Exception: " , new NullPointerException("Test"));
+        verify("List", "o.a.l.l.j.LoggerTest Exception:  MDC{}" + Constants.LINE_SEPARATOR);
+        logger.info("Info Message");
+        verify("List", "o.a.l.l.j.LoggerTest Info Message MDC{}" + Constants.LINE_SEPARATOR);
+        logger.info("Info Message {}");
+        verify("List", "o.a.l.l.j.LoggerTest Info Message {} MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    private void verify(final String name, final String expected) {
+        final ListAppender listApp = context.getListAppender(name);
+        final List<String> events = listApp.getMessages();
+        assertThat(events, hasSize(1));
+        final String actual = events.get(0);
+        assertThat(actual, equalTo(expected));
+        listApp.clear();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CallerInformationTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CallerInformationTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CallerInformationTest.java
index 04fe136..dedaa4e 100644
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CallerInformationTest.java
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CallerInformationTest.java
@@ -1,78 +1,78 @@
-/*
- * 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.jul;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class CallerInformationTest {
-
-    // config from log4j-core test-jar
-    private static final String CONFIG = "log4j2-calling-class.xml";
-
-    @Rule
-    public final InitialLoggerContext ctx = new InitialLoggerContext(CONFIG);
-
-    @BeforeClass
-    public static void setUpClass() {
-        System.setProperty("java.util.logging.manager", LogManager.class.getName());
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        System.clearProperty("java.util.logging.manager");
-    }
-
-    @Test
-    public void testClassLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Class").clear();
-        final Logger logger = Logger.getLogger("ClassLogger");
-        logger.info("Ignored message contents.");
-        logger.warning("Verifying the caller class is still correct.");
-        logger.severe("Hopefully nobody breaks me!");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 3, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
-        }
-    }
-
-    @Test
-    public void testMethodLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Method").clear();
-        final Logger logger = Logger.getLogger("MethodLogger");
-        logger.info("More messages.");
-        logger.warning("CATASTROPHE INCOMING!");
-        logger.severe("ZOMBIES!!!");
-        logger.warning("brains~~~");
-        logger.info("Itchy. Tasty.");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 5, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.jul;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class CallerInformationTest {
+
+    // config from log4j-core test-jar
+    private static final String CONFIG = "log4j2-calling-class.xml";
+
+    @Rule
+    public final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty("java.util.logging.manager", LogManager.class.getName());
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+        System.clearProperty("java.util.logging.manager");
+    }
+
+    @Test
+    public void testClassLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Class").clear();
+        final Logger logger = Logger.getLogger("ClassLogger");
+        logger.info("Ignored message contents.");
+        logger.warning("Verifying the caller class is still correct.");
+        logger.severe("Hopefully nobody breaks me!");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 3, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
+        }
+    }
+
+    @Test
+    public void testMethodLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Method").clear();
+        final Logger logger = Logger.getLogger("MethodLogger");
+        logger.info("More messages.");
+        logger.warning("CATASTROPHE INCOMING!");
+        logger.severe("ZOMBIES!!!");
+        logger.warning("brains~~~");
+        logger.info("Itchy. Tasty.");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 5, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/MongoDbTest.java
----------------------------------------------------------------------
diff --git a/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/MongoDbTest.java b/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/MongoDbTest.java
index 2b061c6..2513526 100644
--- a/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/MongoDbTest.java
+++ b/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/MongoDbTest.java
@@ -1,37 +1,37 @@
-/*
- * 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.nosql.appender;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore("Requires a running MongoDB server")
-public class MongoDbTest {
-
-    @ClassRule
-    public static InitialLoggerContext context = new InitialLoggerContext("log4j2-mongodb.xml");
-
-    @Test
-    public void test() {
-        final Logger logger = LogManager.getLogger();
-        logger.info("Hello log");
-    }
-}
+/*
+ * 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.nosql.appender;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("Requires a running MongoDB server")
+public class MongoDbTest {
+
+    @ClassRule
+    public static LoggerContextRule context = new LoggerContextRule("log4j2-mongodb.xml");
+
+    @Test
+    public void test() {
+        final Logger logger = LogManager.getLogger();
+        logger.info("Hello log");
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
index 255d911..a3e59f0 100644
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
+++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/CallerInformationTest.java
@@ -1,67 +1,67 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.slf4j;
-
-import java.util.List;
-
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Rule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-
-public class CallerInformationTest {
-
-    // config from log4j-core test-jar
-    private static final String CONFIG = "log4j2-calling-class.xml";
-
-    @Rule
-    public final InitialLoggerContext ctx = new InitialLoggerContext(CONFIG);
-
-    @Test
-    public void testClassLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Class").clear();
-        final Logger logger = LoggerFactory.getLogger("ClassLogger");
-        logger.info("Ignored message contents.");
-        logger.warn("Verifying the caller class is still correct.");
-        logger.error("Hopefully nobody breaks me!");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 3, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
-        }
-    }
-
-    @Test
-    public void testMethodLogger() throws Exception {
-        final ListAppender app = ctx.getListAppender("Method").clear();
-        final Logger logger = LoggerFactory.getLogger("MethodLogger");
-        logger.info("More messages.");
-        logger.warn("CATASTROPHE INCOMING!");
-        logger.error("ZOMBIES!!!");
-        logger.warn("brains~~~");
-        logger.info("Itchy. Tasty.");
-        final List<String> messages = app.getMessages();
-        assertEquals("Incorrect number of messages.", 5, messages.size());
-        for (final String message : messages) {
-            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.slf4j;
+
+import java.util.List;
+
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertEquals;
+
+public class CallerInformationTest {
+
+    // config from log4j-core test-jar
+    private static final String CONFIG = "log4j2-calling-class.xml";
+
+    @Rule
+    public final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
+
+    @Test
+    public void testClassLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Class").clear();
+        final Logger logger = LoggerFactory.getLogger("ClassLogger");
+        logger.info("Ignored message contents.");
+        logger.warn("Verifying the caller class is still correct.");
+        logger.error("Hopefully nobody breaks me!");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 3, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
+        }
+    }
+
+    @Test
+    public void testMethodLogger() throws Exception {
+        final ListAppender app = ctx.getListAppender("Method").clear();
+        final Logger logger = LoggerFactory.getLogger("MethodLogger");
+        logger.info("More messages.");
+        logger.warn("CATASTROPHE INCOMING!");
+        logger.error("ZOMBIES!!!");
+        logger.warn("brains~~~");
+        logger.info("Itchy. Tasty.");
+        final List<String> messages = app.getMessages();
+        assertEquals("Incorrect number of messages.", 5, messages.size());
+        for (final String message : messages) {
+            assertEquals("Incorrect caller method name.", "testMethodLogger", message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/546f4d04/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
index 7ed538a..0fa6e65 100644
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
+++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
@@ -1,182 +1,182 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.slf4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.ext.EventData;
-import org.slf4j.ext.EventLogger;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-import org.slf4j.spi.LocationAwareLogger;
-
-/**
- *
- */
-public class LoggerTest {
-
-    private static final String CONFIG = "log4j-test1.xml";
-
-    @ClassRule
-    public static InitialLoggerContext ctx = new InitialLoggerContext(CONFIG);
-
-    Logger logger = LoggerFactory.getLogger("LoggerTest");
-    XLogger xlogger = XLoggerFactory.getXLogger("LoggerTest");
-
-    @Test
-    public void basicFlow() {
-        xlogger.entry();
-        verify("List", "o.a.l.s.LoggerTest entry MDC{}" + Constants.LINE_SEPARATOR);
-        xlogger.exit();
-        verify("List", "o.a.l.s.LoggerTest exit MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    @Test
-    public void simpleFlow() {
-        xlogger.entry(CONFIG);
-        verify("List", "o.a.l.s.LoggerTest entry with (log4j-test1.xml) MDC{}" + Constants.LINE_SEPARATOR);
-        xlogger.exit(0);
-        verify("List", "o.a.l.s.LoggerTest exit with (0) MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    @Test
-    public void throwing() {
-        xlogger.throwing(new IllegalArgumentException("Test Exception"));
-        verify("List", "o.a.l.s.LoggerTest throwing MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    @Test
-    public void catching() {
-        try {
-            throw new NullPointerException();
-        } catch (final Exception e) {
-            xlogger.catching(e);
-            verify("List", "o.a.l.s.LoggerTest catching MDC{}" + Constants.LINE_SEPARATOR);
-        }
-    }
-
-    @Test
-    public void debug() {
-        logger.debug("Debug message");
-        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    @Test
-    public void debugNoParms() {
-        logger.debug("Debug message {}");
-        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEPARATOR);
-        logger.debug("Debug message {}", (Object[]) null);
-        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEPARATOR);
-        ((LocationAwareLogger)logger).log(null, Log4jLogger.class.getName(), LocationAwareLogger.DEBUG_INT,
-            "Debug message {}", null, null);
-        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-
-    @Test
-    public void debugWithParms() {
-        logger.debug("Hello, {}", "World");
-        verify("List", "o.a.l.s.LoggerTest Hello, World MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    @Test
-    public void mdc() {
-
-        MDC.put("TestYear", "2010");
-        logger.debug("Debug message");
-        verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Constants.LINE_SEPARATOR);
-        MDC.clear();
-        logger.debug("Debug message");
-        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    /**
-     * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-793">LOG4J2-793</a>
-     */
-    @Test
-    public void supportsCustomSLF4JMarkers() {
-        final Marker marker = new CustomFlatMarker("TEST");
-        logger.debug(marker, "Test");
-        verify("List", "o.a.l.s.LoggerTest Test MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    @Test
-    public void testRootLogger() {
-        final Logger l = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
-        assertNotNull("No Root Logger", l);
-        assertEquals(Logger.ROOT_LOGGER_NAME, l.getName());
-    }
-
-    @Test
-    public void doubleSubst() {
-        logger.debug("Hello, {}", "Log4j {}");
-        verify("List", "o.a.l.s.LoggerTest Hello, Log4j {} MDC{}" + Constants.LINE_SEPARATOR);
-        xlogger.debug("Hello, {}", "Log4j {}");
-        verify("List", "o.a.l.s.LoggerTest Hello, Log4j Log4j {} MDC{}" + Constants.LINE_SEPARATOR);
-    }
-
-    @Test
-    public void testEventLogger() {
-        MDC.put("loginId", "JohnDoe");
-        MDC.put("ipAddress", "192.168.0.120");
-        MDC.put("locale", Locale.US.getDisplayName());
-        final EventData data = new EventData();
-        data.setEventType("Transfer");
-        data.setEventId("Audit@18060");
-        data.setMessage("Transfer Complete");
-        data.put("ToAccount", "123456");
-        data.put("FromAccount", "123457");
-        data.put("Amount", "200.00");
-        EventLogger.logEvent(data);
-        MDC.clear();
-        verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Constants.LINE_SEPARATOR);
-    }
-
-    private void verify(final String name, final String expected) {
-        final ListAppender listApp = ctx.getListAppender(name);
-        assertNotNull("Missing Appender", listApp);
-        final List<String> events = listApp.getMessages();
-        assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
-        final String actual = events.get(0);
-        assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
-        listApp.clear();
-    }
-
-    @Before
-    @After
-    public void cleanup() {
-        MDC.clear();
-        ctx.getListAppender("List").clear();
-        ctx.getListAppender("EventLogger").clear();
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.slf4j;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.ext.EventData;
+import org.slf4j.ext.EventLogger;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+import org.slf4j.spi.LocationAwareLogger;
+
+/**
+ *
+ */
+public class LoggerTest {
+
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @ClassRule
+    public static LoggerContextRule ctx = new LoggerContextRule(CONFIG);
+
+    Logger logger = LoggerFactory.getLogger("LoggerTest");
+    XLogger xlogger = XLoggerFactory.getXLogger("LoggerTest");
+
+    @Test
+    public void basicFlow() {
+        xlogger.entry();
+        verify("List", "o.a.l.s.LoggerTest entry MDC{}" + Constants.LINE_SEPARATOR);
+        xlogger.exit();
+        verify("List", "o.a.l.s.LoggerTest exit MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    @Test
+    public void simpleFlow() {
+        xlogger.entry(CONFIG);
+        verify("List", "o.a.l.s.LoggerTest entry with (log4j-test1.xml) MDC{}" + Constants.LINE_SEPARATOR);
+        xlogger.exit(0);
+        verify("List", "o.a.l.s.LoggerTest exit with (0) MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    @Test
+    public void throwing() {
+        xlogger.throwing(new IllegalArgumentException("Test Exception"));
+        verify("List", "o.a.l.s.LoggerTest throwing MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    @Test
+    public void catching() {
+        try {
+            throw new NullPointerException();
+        } catch (final Exception e) {
+            xlogger.catching(e);
+            verify("List", "o.a.l.s.LoggerTest catching MDC{}" + Constants.LINE_SEPARATOR);
+        }
+    }
+
+    @Test
+    public void debug() {
+        logger.debug("Debug message");
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    @Test
+    public void debugNoParms() {
+        logger.debug("Debug message {}");
+        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEPARATOR);
+        logger.debug("Debug message {}", (Object[]) null);
+        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEPARATOR);
+        ((LocationAwareLogger)logger).log(null, Log4jLogger.class.getName(), LocationAwareLogger.DEBUG_INT,
+            "Debug message {}", null, null);
+        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+
+    @Test
+    public void debugWithParms() {
+        logger.debug("Hello, {}", "World");
+        verify("List", "o.a.l.s.LoggerTest Hello, World MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    @Test
+    public void mdc() {
+
+        MDC.put("TestYear", "2010");
+        logger.debug("Debug message");
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Constants.LINE_SEPARATOR);
+        MDC.clear();
+        logger.debug("Debug message");
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    /**
+     * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-793">LOG4J2-793</a>
+     */
+    @Test
+    public void supportsCustomSLF4JMarkers() {
+        final Marker marker = new CustomFlatMarker("TEST");
+        logger.debug(marker, "Test");
+        verify("List", "o.a.l.s.LoggerTest Test MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    @Test
+    public void testRootLogger() {
+        final Logger l = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        assertNotNull("No Root Logger", l);
+        assertEquals(Logger.ROOT_LOGGER_NAME, l.getName());
+    }
+
+    @Test
+    public void doubleSubst() {
+        logger.debug("Hello, {}", "Log4j {}");
+        verify("List", "o.a.l.s.LoggerTest Hello, Log4j {} MDC{}" + Constants.LINE_SEPARATOR);
+        xlogger.debug("Hello, {}", "Log4j {}");
+        verify("List", "o.a.l.s.LoggerTest Hello, Log4j Log4j {} MDC{}" + Constants.LINE_SEPARATOR);
+    }
+
+    @Test
+    public void testEventLogger() {
+        MDC.put("loginId", "JohnDoe");
+        MDC.put("ipAddress", "192.168.0.120");
+        MDC.put("locale", Locale.US.getDisplayName());
+        final EventData data = new EventData();
+        data.setEventType("Transfer");
+        data.setEventId("Audit@18060");
+        data.setMessage("Transfer Complete");
+        data.put("ToAccount", "123456");
+        data.put("FromAccount", "123457");
+        data.put("Amount", "200.00");
+        EventLogger.logEvent(data);
+        MDC.clear();
+        verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Constants.LINE_SEPARATOR);
+    }
+
+    private void verify(final String name, final String expected) {
+        final ListAppender listApp = ctx.getListAppender(name);
+        assertNotNull("Missing Appender", listApp);
+        final List<String> events = listApp.getMessages();
+        assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
+        final String actual = events.get(0);
+        assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
+        listApp.clear();
+    }
+
+    @Before
+    @After
+    public void cleanup() {
+        MDC.clear();
+        ctx.getListAppender("List").clear();
+        ctx.getListAppender("EventLogger").clear();
+    }
+}


[03/12] logging-log4j2 git commit: [LOG4J2-1108] NullPointerException when passing null to java.util.logging.Logger.setLevel().

Posted by rg...@apache.org.
[LOG4J2-1108] NullPointerException when passing null to
java.util.logging.Logger.setLevel().

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

Branch: refs/heads/LOG4J2-952
Commit: 81e2fa4c347f92ecb05aa000e939adfe310f935a
Parents: 2b1b356
Author: ggregory <gg...@apache.org>
Authored: Fri Aug 28 11:42:56 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Aug 28 11:42:56 2015 -0700

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/Logger.java   |  9 +++++-
 .../log4j/jul/DefaultLevelConverter.java        |  3 ++
 .../logging/log4j/jul/LevelConverter.java       |  2 +-
 .../logging/log4j/jul/LevelTranslator.java      |  4 +--
 .../logging/log4j/jul/CoreLoggerTest.java       | 20 +++++++++++++
 .../log4j/jul/DefaultLevelConverterTest.java    | 31 ++++++++++++++++++++
 src/changes/changes.xml                         |  3 ++
 7 files changed, 68 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/81e2fa4c/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
index 81a86c9..1e02387 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
@@ -97,11 +97,18 @@ public class Logger extends AbstractLogger {
 
     /**
      * This method is not exposed through the public API and is provided primarily for unit testing.
-     * @param level The Level to use on this Logger.
+     * <p>
+     * If the new level is null, this logger inherits the level from its parent.
+     * </p>
+     * 
+     * @param level The Level to use on this Logger, may be null.
      */
     public synchronized void setLevel(final Level level) {
         if (level != null) {
             config = new PrivateConfig(config, level);
+        } else {
+            // Reusing parent PC, should we make a copy instead?
+            config = getParent().config;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/81e2fa4c/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
index 8648627..23ea0f9 100644
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
@@ -116,6 +116,9 @@ public class DefaultLevelConverter implements LevelConverter {
 
     @Override
     public Level toLevel(final java.util.logging.Level javaLevel) {
+        if (javaLevel == null) {
+            return null;
+        }
         final Level level = julToLog4j.get(javaLevel);
         if (level != null) {
             return level;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/81e2fa4c/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelConverter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelConverter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelConverter.java
index 22ddad6..95676f6 100644
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelConverter.java
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelConverter.java
@@ -31,7 +31,7 @@ public interface LevelConverter {
     /**
      * Converts a JDK logging Level to a Log4j logging Level.
      *
-     * @param javaLevel JDK Level to convert.
+     * @param javaLevel JDK Level to convert, may be null per the JUL specification.
      * @return converted Level or {@code null} if the given level could not be converted.
      */
     Level toLevel(java.util.logging.Level javaLevel);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/81e2fa4c/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelTranslator.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelTranslator.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelTranslator.java
index c64c380..328e1e5 100644
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelTranslator.java
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LevelTranslator.java
@@ -65,8 +65,8 @@ public final class LevelTranslator {
     /**
      * Converts a JDK logging Level to a Log4j logging Level.
      *
-     * @param level JDK Level to convert.
-     * @return converted Level.
+     * @param level JDK Level to convert, may be null per the JUL specification.
+     * @return converted Level or null
      */
     public static Level toLevel(final java.util.logging.Level level) {
         return LEVEL_CONVERTER.toLevel(level);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/81e2fa4c/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java
index 297afa5..ccb761f 100644
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java
@@ -18,6 +18,7 @@
 package org.apache.logging.log4j.jul;
 
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
 import java.util.logging.Level;
@@ -73,4 +74,23 @@ public class CoreLoggerTest extends AbstractLoggerTest {
         assertThat(logger.getLevel(), equalTo(Level.FINE));
         assertThat(childLogger.getLevel(), equalTo(Level.FINE));
     }
+
+    @Test
+    public void testSetLevelToNull() throws Exception {
+        final Logger childLogger = Logger.getLogger(LOGGER_NAME + ".NullChild");
+        assertThat(childLogger.getLevel(), equalTo(Level.FINE));
+        assertThat(childLogger.isLoggable(Level.FINE), is(true));
+        childLogger.setLevel(Level.SEVERE);
+        assertThat(childLogger.getLevel(), equalTo(Level.SEVERE));
+        assertThat(childLogger.isLoggable(Level.FINE), is(false));
+        // null test
+        childLogger.setLevel(null);
+        assertThat(childLogger.getLevel(), equalTo(null));
+        assertThat(childLogger.isLoggable(Level.FINE), is(true));
+        // now go back
+        childLogger.setLevel(Level.SEVERE);
+        assertThat(childLogger.getLevel(), equalTo(Level.SEVERE));
+        assertThat(childLogger.isLoggable(Level.FINE), is(false));
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/81e2fa4c/log4j-jul/src/test/java/org/apache/logging/log4j/jul/DefaultLevelConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/DefaultLevelConverterTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/DefaultLevelConverterTest.java
new file mode 100644
index 0000000..801749e
--- /dev/null
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/DefaultLevelConverterTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.jul;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DefaultLevelConverterTest {
+
+    /**
+     * (LOG4J2-1108) NullPointerException when passing null to java.util.logging.Logger.setLevel().
+     */
+    @Test
+    public void testJulSetNull() {
+        Assert.assertEquals(null, new DefaultLevelConverter().toLevel(null));
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/81e2fa4c/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 509a993..f33e78d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,6 +45,9 @@
       <action issue="LOG4J2-1044" dev="rgoers" type="fix">
         Write pending events to Flume when the appender is stopped.
       </action>
+      <action issue="LOG4J2-1108" dev="ggregory" type="fix" due-to="Mikael Ståldal">
+        NullPointerException when passing null to java.util.logging.Logger.setLevel().
+      </action>
       <action dev="rpopma" type="remove">
         Removed experimental interface LevelLogger which got committed to master by mistake.
       </action>


[06/12] logging-log4j2 git commit: Only change the level if it is different from the current level.

Posted by rg...@apache.org.
Only change the level if it is different from the current level.

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

Branch: refs/heads/LOG4J2-952
Commit: 32956ad361808ffa412a5867bbb34859df3e94db
Parents: f14bc48
Author: ggregory <gg...@apache.org>
Authored: Fri Aug 28 12:54:41 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Aug 28 12:54:41 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/32956ad3/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
index 91ce841..667e9ac 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
@@ -104,6 +104,9 @@ public class Logger extends AbstractLogger {
      * @param level The Level to use on this Logger, may be null.
      */
     public synchronized void setLevel(final Level level) {
+        if (level == getLevel()) {
+            return;
+        }
         final Level actualLevel = level != null ? level : getParent().getLevel();
         config = new PrivateConfig(config, actualLevel);
     }