logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1184931 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers: log4j2-api/src/main/java/org/apache/logging/log4j/ log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ slf4j-impl/src/main/java/org/slf4j/helpers/ slf4j-impl/...
Date Sun, 16 Oct 2011 20:55:38 GMT
Author: rgoers
Date: Sun Oct 16 20:55:37 2011
New Revision: 1184931

URL: http://svn.apache.org/viewvc?rev=1184931&view=rev
Log:
Detect request for SLF4J Root Logger and map to Log4j 2.0 root logger.

Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/architecture.xml

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java?rev=1184931&r1=1184930&r2=1184931&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
Sun Oct 16 20:55:37 2011
@@ -32,6 +32,8 @@ import java.util.Properties;
  */
 public class LogManager {
 
+    public static final String ROOT_LOGGER_NAME = "";
+
     private static final String LOGGER_RESOURCE = "META-INF/log4j-provider.xml";
     private static final String LOGGER_CONTEXT_FACTORY = "LoggerContextFactory";
     private static final String API_VERSION = "Log4jAPIVersion";

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java?rev=1184931&r1=1184930&r2=1184931&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
Sun Oct 16 20:55:37 2011
@@ -17,6 +17,7 @@
 package org.apache.logging.log4j.core.config;
 
 import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.core.Appender;
@@ -310,7 +311,7 @@ public class LoggerConfig extends Filter
             Level level = loggerLevel == null ? Level.ERROR : Level.valueOf(loggerLevel.toUpperCase());
             boolean additive = additivity == null ? true : Boolean.parseBoolean(additivity);
 
-            return new LoggerConfig("", appenderRefs, filters, level, additive);
+            return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filters, level,
additive);
         }
     }
 

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java?rev=1184931&r1=1184930&r2=1184931&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
Sun Oct 16 20:55:37 2011
@@ -44,10 +44,12 @@ public class Log4JLoggerFactory implemen
     public Logger getLogger(String name) {
         LoggerContext context = getContext();
         ConcurrentMap<String, Logger> loggers = getLoggersMap(context);
+
         if (loggers.containsKey(name)) {
             return loggers.get(name);
         }
-        org.apache.logging.log4j.Logger logger = context.getLogger(name);
+        String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME :
name;
+        org.apache.logging.log4j.Logger logger = context.getLogger(key);
         if (logger instanceof AbstractLogger) {
             loggers.putIfAbsent(name, new SLF4JLogger((AbstractLogger) logger, name));
             return loggers.get(name);

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java?rev=1184931&r1=1184930&r2=1184931&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
Sun Oct 16 20:55:37 2011
@@ -139,6 +139,13 @@ public class LoggerTest {
     }
 
     @Test
+    public void testRootLogger() {
+        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{}\n");

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/architecture.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/architecture.xml?rev=1184931&r1=1184930&r2=1184931&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/architecture.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/site/xdoc/manual/architecture.xml
Sun Oct 16 20:55:37 2011
@@ -77,12 +77,9 @@
             </p>
 
             <p>The root logger resides at the top of the logger hierarchy. It
-               is exceptional in two ways:
-
-              <ol>
-                <li> it always exists,</li>
-                <li> it does not have a name.</li>
-              </ol>
+              is exceptional in that it always exists and it is part of every hierarchy.
It can
+              be obtained as follows:
+              <source>Logger logger = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);</source>
             </p>
           <h4>LoggerContext</h4>
 



Mime
View raw message