logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpo...@apache.org
Subject svn commit: r1580445 [2/2] - in /logging/log4j/log4j2/trunk: log4j-1.2-api/src/main/java/org/apache/log4j/ log4j-api/src/main/java/org/apache/logging/log4j/ log4j-api/src/main/java/org/apache/logging/log4j/simple/ log4j-api/src/main/java/org/apache/log...
Date Sun, 23 Mar 2014 04:50:15 GMT
Modified: logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java Sun Mar 23 04:50:14 2014
@@ -272,42 +272,6 @@ public class LoggerTest {
     }
 
     @Test
-    public void getStream() {
-        final PrintWriter stream = logger.printWriter(Level.DEBUG);
-        stream.println("println");
-        stream.print("print followed by println");
-        stream.println();
-        stream.println("multiple\nlines");
-        stream.println(); // verify blank log message
-        stream.print("print embedded newline\n");
-        stream.print("\r\n"); // verify windows EOL works
-        stream.print("Last Line without newline");
-        stream.close();
-        assertEquals(8, results.size());
-        assertEquals("msg 1", " DEBUG println", results.get(0));
-        assertEquals("msg 2", " DEBUG print followed by println", results.get(1));
-        assertEquals("msg 3", " DEBUG multiple", results.get(2));
-        assertEquals("msg 4", " DEBUG lines", results.get(3));
-        assertEquals("msg 5 should be blank-ish", " DEBUG ", results.get(4));
-        assertEquals("msg 6", " DEBUG print embedded newline", results.get(5));
-        assertEquals("msg 7 should be blank-ish", " DEBUG ", results.get(6));
-        assertEquals("msg 8 Last line", " DEBUG Last Line without newline", results.get(7));
-    }
-
-    @Test
-    public void getStream_Marker() {
-        final PrintWriter stream = logger.printWriter(MarkerManager.getMarker("HI"), Level.INFO);
-        stream.println("println");
-        stream.print("print with embedded newline\n");
-        stream.println("last line");
-        stream.close();
-        assertEquals(3, results.size());
-        assertEquals("println 1", "HI INFO println", results.get(0));
-        assertEquals("print with embedded newline", "HI INFO print with embedded newline", results.get(1));
-        assertEquals("println 2", "HI INFO last line", results.get(2));
-    }
-
-    @Test
     public void isAllEnabled() {
         assertTrue("Incorrect level", logger.isEnabled(Level.ALL));
     }

Modified: logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java (original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLogger.java Sun Mar 23 04:50:14 2014
@@ -52,7 +52,7 @@ public class TestLogger extends Abstract
     }
 
     @Override
-    public void log(final Marker marker, final String fqcn, final Level level, final Message msg, final Throwable throwable) {
+    public void logMessage(final String fqcn, final Level level, final Marker marker, final Message msg, final Throwable throwable) {
         final StringBuilder sb = new StringBuilder();
         if (marker != null) {
             sb.append(marker);
@@ -85,28 +85,28 @@ public class TestLogger extends Abstract
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final String msg) {
+    public boolean isEnabled(final Level level, final Marker marker, final String msg) {
         return true;
     }
 
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final String msg, final Throwable t) {
+    public boolean isEnabled(final Level level, final Marker marker, final String msg, final Throwable t) {
         return true;
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final String msg, final Object... p1) {
+    public boolean isEnabled(final Level level, final Marker marker, final String msg, final Object... p1) {
         return true;
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final Object msg, final Throwable t) {
+    public boolean isEnabled(final Level level, final Marker marker, final Object msg, final Throwable t) {
         return true;
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final Message msg, final Throwable t) {
+    public boolean isEnabled(final Level level, final Marker marker, final Message msg, final Throwable t) {
         return true;
     }
 }

Modified: logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java (original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java Sun Mar 23 04:50:14 2014
@@ -18,6 +18,7 @@ package org.apache.logging.log4j;
 
 import org.apache.logging.log4j.message.MessageFactory;
 import org.apache.logging.log4j.spi.LoggerContext;
+import org.apache.logging.log4j.spi.LoggerProvider;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -26,20 +27,20 @@ import java.util.Map;
  *
  */
 public class TestLoggerContext implements LoggerContext {
-    private final Map<String, Logger> map = new HashMap<String, Logger>();
+    private final Map<String, LoggerProvider> map = new HashMap<String, LoggerProvider>();
 
     @Override
-    public Logger getLogger(final String name) {
+    public LoggerProvider getLogger(final String name) {
         if (map.containsKey(name)) {
             return map.get(name);
         }
-        final Logger logger = new TestLogger(name);
+        final LoggerProvider logger = new TestLogger(name);
         map.put(name, logger);
         return logger;
     }
 
     @Override
-    public Logger getLogger(final String name, final MessageFactory messageFactory) {
+    public LoggerProvider getLogger(final String name, final MessageFactory messageFactory) {
         return new TestLogger(name, messageFactory);
     }
 

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java Sun Mar 23 04:50:14 2014
@@ -104,37 +104,35 @@ public class Logger extends AbstractLogg
     }
 
     @Override
-    public void log(final Marker marker, final String fqcn, final Level level, Message data, final Throwable t) {
-        if (data == null) {
-            data = new SimpleMessage("");
-        }
+    public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
+        final Message msg = message == null ? new SimpleMessage("") : message;
         config.config.getConfigurationMonitor().checkConfiguration();
-        config.loggerConfig.log(getName(), marker, fqcn, level, data, t);
+        config.loggerConfig.log(getName(), fqcn, marker, level, msg, t);
     }
 
     @Override
-    public boolean isEnabled(final Level level, final Marker marker, final String msg) {
-        return config.filter(level, marker, msg);
+    public boolean isEnabled(final Level level, final Marker marker, final String message, final Throwable t) {
+        return config.filter(level, marker, message, t);
     }
 
     @Override
-    public boolean isEnabled(final Level level, final Marker marker, final String msg, final Throwable t) {
-        return config.filter(level, marker, msg, t);
+    public boolean isEnabled(final Level level, final Marker marker, final String message) {
+        return config.filter(level, marker, message);
     }
 
     @Override
-    public boolean isEnabled(final Level level, final Marker marker, final String msg, final Object... p1) {
-        return config.filter(level, marker, msg, p1);
+    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object... params) {
+        return config.filter(level, marker, message, params);
     }
 
     @Override
-    public boolean isEnabled(final Level level, final Marker marker, final Object msg, final Throwable t) {
-        return config.filter(level, marker, msg, t);
+    public boolean isEnabled(final Level level, final Marker marker, final Object message, final Throwable t) {
+        return config.filter(level, marker, message, t);
     }
 
     @Override
-    public boolean isEnabled(final Level level, final Marker marker, final Message msg, final Throwable t) {
-        return config.filter(level, marker, msg, t);
+    public boolean isEnabled(final Level level, final Marker marker, final Message message, final Throwable t) {
+        return config.filter(level, marker, message, t);
     }
 
     /**

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java Sun Mar 23 04:50:14 2014
@@ -230,7 +230,7 @@ public class AsyncLogger extends Logger 
     }
 
     @Override
-    public void log(final Marker marker, final String fqcn, final Level level, final Message data, final Throwable t) {
+    public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
         Info info = threadlocalInfo.get();
         if (info == null) {
             info = new Info(new RingBufferLogEventTranslator(), Thread.currentThread().getName(), false);
@@ -241,11 +241,11 @@ public class AsyncLogger extends Logger 
         // being logged calls Logger.log() from its toString() method
         if (info.isAppenderThread && disruptor.getRingBuffer().remainingCapacity() == 0) {
             // bypass RingBuffer and invoke Appender directly
-            config.loggerConfig.log(getName(), marker, fqcn, level, data, t);
+            config.loggerConfig.log(getName(), fqcn, marker, level, message, t);
             return;
         }
         final boolean includeLocation = config.loggerConfig.isIncludeLocation();
-        info.translator.setValues(this, getName(), marker, fqcn, level, data, t, //
+        info.translator.setValues(this, getName(), marker, fqcn, level, message, t, //
 
                 // config properties are taken care of in the EventHandler
                 // thread in the #actualAsyncLog method

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java Sun Mar 23 04:50:14 2014
@@ -341,14 +341,14 @@ public class LoggerConfig extends Abstra
      * Logs an event.
      *
      * @param loggerName The name of the Logger.
-     * @param marker A Marker or null if none is present.
      * @param fqcn The fully qualified class name of the caller.
+     * @param marker A Marker or null if none is present.
      * @param level The event Level.
      * @param data The Message.
      * @param t A Throwable or null.
      */
-    public void log(final String loggerName, final Marker marker,
-            final String fqcn, final Level level, final Message data,
+    public void log(final String loggerName, final String fqcn,
+            final Marker marker, final Level level, final Message data,
             final Throwable t) {
         List<Property> props = null;
         if (properties != null) {

Added: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java?rev=1580445&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java (added)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java Sun Mar 23 04:50:14 2014
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core;
+
+import static org.apache.logging.log4j.Level.*;
+import static org.junit.Assert.*;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.MarkerManager;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.ObjectMessage;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class LevelTest {
+
+    private static final String CONFIG = "log4j-Level.xml";
+    private static LoggerContext ctx;
+    private static ListAppender listAll;
+    private static ListAppender listTrace;
+    private static ListAppender listDebug;
+    private static ListAppender listInfo;
+    private static ListAppender listWarn;
+    private static ListAppender listError;
+    private static ListAppender listFatal;
+
+    @BeforeClass
+    public static void setupClass() {
+        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        ctx = (LoggerContext) LogManager.getContext(false);
+    }
+
+    @AfterClass
+    public static void cleanupClass() {
+        System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        ctx.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    @Before
+    public void before() {
+        Configuration config = ctx.getConfiguration();
+        for (final Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
+            if (entry.getKey().equals("ListAll")) {
+                listAll = (ListAppender) entry.getValue();
+            } else if (entry.getKey().equals("ListTrace")) {
+                listTrace = (ListAppender) entry.getValue();
+            } else if (entry.getKey().equals("ListDebug")) {
+                listDebug = (ListAppender) entry.getValue();
+            } else if (entry.getKey().equals("ListInfo")) {
+                listInfo = (ListAppender) entry.getValue();
+            } else if (entry.getKey().equals("ListWarn")) {
+                listWarn = (ListAppender) entry.getValue();
+            } else if (entry.getKey().equals("ListError")) {
+                listError = (ListAppender) entry.getValue();
+            } else if (entry.getKey().equals("ListFatal")) {
+                listFatal = (ListAppender) entry.getValue();
+            }
+        }
+        assertNotNull("No listAll Appender", listAll);
+        assertNotNull("No listTrace Appender", listTrace);
+        assertNotNull("No listDebug Appender", listDebug);
+        assertNotNull("No listInfo Appender", listInfo);
+        assertNotNull("No listWarn Appender", listWarn);
+        assertNotNull("No listError Appender", listError);
+        assertNotNull("No listFatal Appender", listFatal);
+        listAll.clear();
+        listTrace.clear();
+        listDebug.clear();
+        listInfo.clear();
+        listWarn.clear();
+        listError.clear();
+        listFatal.clear();
+    }
+
+    // Helper class
+    class Expected {
+        final ListAppender appender;
+        final int expectedEventCount;
+        final String expectedInitialEventLevel;
+        final String description;
+
+        Expected(ListAppender appender, int expectedCount, String level, String description) {
+            this.appender = appender;
+            this.expectedEventCount = expectedCount;
+            this.expectedInitialEventLevel = level;
+            this.description = description;
+        }
+    }
+
+    @Test
+    public void testLevelLogging() {
+        Marker marker = MarkerManager.getMarker("marker");
+        Message msg = new ObjectMessage("msg");
+        Throwable t = new Throwable("test");
+        Level[] levels = new Level[] { TRACE, DEBUG, INFO, WARN, ERROR, FATAL };
+        String[] names = new String[] { "levelTest", "levelTest.Trace", "levelTest.Debug", "levelTest.Info",
+                "levelTest.Warn", "levelTest.Error", "levelTest.Fatal" };
+        for (Level level : levels) {
+            for (String name : names) {
+                org.apache.logging.log4j.Logger logger = LogManager.getLogger(name);
+                logger.log(level, msg); // Message
+                logger.log(level, 123); // Object
+                logger.log(level, name); // String
+                logger.log(level, marker, msg); // Marker, Message
+                logger.log(level, marker, 123); // Marker, Object
+                logger.log(level, marker, name); // marker, String
+                logger.log(level, msg, t); // Message, Throwable
+                logger.log(level, 123, t); // Object, Throwable
+                logger.log(level, name, "param1", "param2"); // String, Object...
+                logger.log(level, name, t); // String, Throwable
+                logger.log(level, marker, msg, t); // Marker, Message, Throwable
+                logger.log(level, marker, 123, t); // Marker, Object, Throwable
+                logger.log(level, marker, name, "param1", "param2"); // Marker, String, Object...
+                logger.log(level, marker, name, t); // Marker, String, Throwable
+            }
+        }
+        // Logger "levelTest" will not receive same events as "levelTest.Trace"
+        int levelCount = names.length - 1;
+
+        final int UNIT = 14;
+        Expected[] expectedResults = new Expected[] { //
+        new Expected(listAll, UNIT * levelCount, "TRACE", "All"), //
+                new Expected(listTrace, UNIT * levelCount--, "TRACE", "Trace"), //
+                new Expected(listDebug, UNIT * levelCount--, "DEBUG", "Debug"), //
+                new Expected(listInfo, UNIT * levelCount--, "INFO", "Info"), //
+                new Expected(listWarn, UNIT * levelCount--, "WARN", "Warn"), //
+                new Expected(listError, UNIT * levelCount--, "ERROR", "Error"), //
+                new Expected(listFatal, UNIT * levelCount--, "FATAL", "Fatal"), //
+        };
+        for (Expected expected : expectedResults) {
+            final String description = expected.description;
+            final List<LogEvent> events = expected.appender.getEvents();
+            assertNotNull(description + ": No events", events);
+            assertTrue(description + ": Incorrect number of events. Expected " + expected.expectedEventCount + " got "
+                    + events.size(), events.size() == expected.expectedEventCount);
+            LogEvent event = events.get(0);
+            assertTrue(
+                    description + ": Expected level " + expected.expectedInitialEventLevel + ", got" + event.getLevel(),
+                    event.getLevel().name().equals(expected.expectedInitialEventLevel));
+        }
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LevelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-Level.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-Level.xml?rev=1580445&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-Level.xml (added)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-Level.xml Sun Mar 23 04:50:14 2014
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<Configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
+
+  <Appenders>
+    <Console name="STDOUT">
+      <PatternLayout pattern="%m%n"/>
+    </Console>
+    <List name="ListAll" />
+    <List name="ListTrace" />
+    <List name="ListDebug" />
+    <List name="ListInfo" />
+    <List name="ListWarn" />
+    <List name="ListError" />
+    <List name="ListFatal" />
+  </Appenders>
+
+  <Loggers>
+    <Logger name="levelTest" level="all" additivity="false">
+      <AppenderRef ref="ListAll"/>
+    </Logger>
+    <Logger name="levelTest.Trace" level="trace" additivity="false">
+      <AppenderRef ref="ListTrace"/>
+    </Logger>
+    <Logger name="levelTest.Debug" level="debug" additivity="false">
+      <AppenderRef ref="ListDebug"/>
+    </Logger>
+    <Logger name="levelTest.Info" level="info" additivity="false">
+      <AppenderRef ref="ListInfo"/>
+    </Logger>
+    <Logger name="levelTest.Warn" level="warn" additivity="false">
+      <AppenderRef ref="ListWarn"/>
+    </Logger>
+    <Logger name="levelTest.Error" level="error" additivity="false">
+      <AppenderRef ref="ListError"/>
+    </Logger>
+    <Logger name="levelTest.Fatal" level="fatal" additivity="false">
+      <AppenderRef ref="ListFatal"/>
+    </Logger>
+
+    <Root level="off">
+      <AppenderRef ref="STDOUT"/>
+    </Root>
+  </Loggers>
+
+</Configuration>
\ No newline at end of file

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-Level.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java (original)
+++ logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java Sun Mar 23 04:50:14 2014
@@ -16,18 +16,113 @@
  */
 package org.apache.logging.log4j.jcl;
 
+import java.io.Serializable;
+
 import org.apache.commons.logging.Log;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.spi.LoggerProvider;
 
 /**
  *
  */
-public class Log4jLog extends AbstractLoggerWrapper implements Log {
-
+public class Log4jLog implements Log, Serializable {
+    
     private static final long serialVersionUID = 1L;
+    private static final String FQCN = Log4jLog.class.getName();
+
+    private final LoggerProvider logger;
+
+    public Log4jLog(final LoggerProvider logger) {
+        this.logger = logger;
+    }
+
+    @Override
+    public boolean isDebugEnabled() {
+        return logger.isEnabled(Level.DEBUG, null, null);
+    }
+
+    @Override
+    public boolean isErrorEnabled() {
+        return logger.isEnabled(Level.ERROR, null, null);
+    }
+
+    @Override
+    public boolean isFatalEnabled() {
+        return logger.isEnabled(Level.FATAL, null, null);
+    }
+
+    @Override
+    public boolean isInfoEnabled() {
+        return logger.isEnabled(Level.INFO, null, null);
+    }
+
+    @Override
+    public boolean isTraceEnabled() {
+        return logger.isEnabled(Level.TRACE, null, null);
+    }
+
+    @Override
+    public boolean isWarnEnabled() {
+        return logger.isEnabled(Level.WARN, null, null);
+    }
+
+    @Override
+    public void trace(Object message) {
+        logger.logIfEnabled(FQCN, Level.TRACE, null, message, null);
+    }
+
+    @Override
+    public void trace(Object message, Throwable t) {
+        logger.logIfEnabled(FQCN, Level.TRACE, null, message, t);
+    }
+
+    @Override
+    public void debug(Object message) {
+        logger.logIfEnabled(FQCN, Level.DEBUG, null, message, null);
+    }
+
+    @Override
+    public void debug(Object message, Throwable t) {
+        logger.logIfEnabled(FQCN, Level.DEBUG, null, message, t);
+    }
+
+    @Override
+    public void info(Object message) {
+        logger.logIfEnabled(FQCN, Level.INFO, null, message, null);
+    }
+
+    @Override
+    public void info(Object message, Throwable t) {
+        logger.logIfEnabled(FQCN, Level.INFO, null, message, t);
+    }
+
+    @Override
+    public void warn(Object message) {
+        logger.logIfEnabled(FQCN, Level.WARN, null, message, null);
+    }
+
+    @Override
+    public void warn(Object message, Throwable t) {
+        logger.logIfEnabled(FQCN, Level.WARN, null, message, t);
+    }
+
+    @Override
+    public void error(Object message) {
+        logger.logIfEnabled(FQCN, Level.ERROR, null, message, null);
+    }
+
+    @Override
+    public void error(Object message, Throwable t) {
+        logger.logIfEnabled(FQCN, Level.ERROR, null, message, t);
+    }
+
+    @Override
+    public void fatal(Object message) {
+        logger.logIfEnabled(FQCN, Level.FATAL, null, message, null);
+    }
 
-    public Log4jLog(final AbstractLogger logger, final String name) {
-        super(logger, name, null);
+    @Override
+    public void fatal(Object message, Throwable t) {
+        logger.logIfEnabled(FQCN, Level.FATAL, null, message, t);
     }
 }

Modified: logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java (original)
+++ logging/log4j/log4j2/trunk/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java Sun Mar 23 04:50:14 2014
@@ -25,8 +25,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogConfigurationException;
 import org.apache.commons.logging.LogFactory;
 import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.spi.AbstractLogger;
 import org.apache.logging.log4j.spi.LoggerContext;
+import org.apache.logging.log4j.spi.LoggerProvider;
 
 /**
  *
@@ -44,13 +44,8 @@ public class LogFactoryImpl extends LogF
         if (loggers.containsKey(name)) {
             return loggers.get(name);
         }
-        final org.apache.logging.log4j.Logger logger = PrivateManager.getLogger(name);
-        if (logger instanceof AbstractLogger) {
-            loggers.putIfAbsent(name, new Log4jLog((AbstractLogger) logger, name));
-            return loggers.get(name);
-        }
-        throw new LogConfigurationException(
-            "Commons Logging Adapter requires base logging system to extend Log4j AbstractLogger");
+        loggers.putIfAbsent(name, new Log4jLog(PrivateManager.getLogger(name)));
+        return loggers.get(name);
     }
 
     private ConcurrentMap<String, Log> getLoggersMap() {
@@ -113,8 +108,8 @@ public class LogFactoryImpl extends LogF
             return getContext(FQCN, false);
         }
 
-        public static org.apache.logging.log4j.Logger getLogger(final String name) {
-            return getLogger(FQCN, name);
+        public static LoggerProvider getLogger(final String name) {
+            return getContext().getLogger(name);
         }
     }
 

Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/Log4jLoggerFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/Log4jLoggerFactory.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/Log4jLoggerFactory.java (original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/helpers/Log4jLoggerFactory.java Sun Mar 23 04:50:14 2014
@@ -22,9 +22,8 @@ import java.util.concurrent.ConcurrentHa
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.spi.AbstractLogger;
 import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.slf4j.SLF4JLoggingException;
+import org.apache.logging.log4j.spi.LoggerProvider;
 import org.slf4j.ILoggerFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,12 +49,8 @@ public class Log4jLoggerFactory implemen
             return loggers.get(name);
         }
         final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
-        final 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);
-        }
-        throw new SLF4JLoggingException("SLF4J Adapter requires base logging system to extend Log4j AbstractLogger");
+        loggers.putIfAbsent(name, new SLF4JLogger(context.getLogger(key), name));
+        return loggers.get(name);
     }
 
     private ConcurrentMap<String, Logger> getLoggersMap(final LoggerContext context) {
@@ -104,9 +99,8 @@ public class Log4jLoggerFactory implemen
             return getContext(fqcn, false);
         }
 
-        public static org.apache.logging.log4j.Logger getLogger(final String name) {
-            return getLogger(FQCN, name);
+        public static LoggerProvider getLogger(final String name) {
+            return getContext(FQCN).getLogger(name);
         }
     }
-
 }

Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java (original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java Sun Mar 23 04:50:14 2014
@@ -16,38 +16,38 @@
  */
 package org.slf4j.impl;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.ParameterizedMessage;
 import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
+import org.apache.logging.log4j.spi.LoggerProvider;
 import org.slf4j.Marker;
 import org.slf4j.MarkerFactory;
 import org.slf4j.helpers.EventDataConverter;
 import org.slf4j.spi.LocationAwareLogger;
 
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
 /**
  *
  */
 public class SLF4JLogger implements LocationAwareLogger, Serializable {
 
+    public static final String FQCN = SLF4JLogger.class.getName();
+    
     private static final long serialVersionUID = 7869000638091304316L;
-    private static final String FQCN = SLF4JLogger.class.getName();
     private static final Marker EVENT_MARKER = MarkerFactory.getMarker("EVENT");
     private final boolean eventLogger;
-    private transient AbstractLoggerWrapper logger;
+    private transient LoggerProvider logger;
     private final String name;
     private transient EventDataConverter converter;
 
-    public SLF4JLogger(final AbstractLogger logger, final String name) {
-        this.logger = new AbstractLoggerWrapper(logger, name, null);
+    public SLF4JLogger(final LoggerProvider logger, final String name) {
+        this.logger = logger;
         this.eventLogger = "EventLogger".equals(name);
         this.name = name;
         this.converter = createConverter();
@@ -55,453 +55,324 @@ public class SLF4JLogger implements Loca
 
     @Override
     public void trace(final String format) {
-        if (logger.isTraceEnabled()) {
-            logger.log(null, FQCN, Level.TRACE, new SimpleMessage(format), null);
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, null, format);
     }
 
     @Override
     public void trace(final String format, final Object o) {
-        if (logger.isTraceEnabled()) {
-            logger.log(null, FQCN, Level.TRACE, new ParameterizedMessage(format, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, null, format, o);
     }
 
     @Override
     public void trace(final String format, final Object arg1, final Object arg2) {
-        if (logger.isTraceEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
-            logger.log(null, FQCN, Level.TRACE, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, null, format, arg1, arg2);
     }
 
     @Override
     public void trace(final String format, final Object... args) {
-        if (logger.isTraceEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, args);
-            logger.log(null, FQCN, Level.TRACE, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, null, format, args);
     }
 
     @Override
     public void trace(final String format, final Throwable t) {
-        if (logger.isTraceEnabled()) {
-            logger.log(null, FQCN, Level.TRACE, new SimpleMessage(format), t);
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, null, format, t);
     }
 
     @Override
     public boolean isTraceEnabled() {
-        return logger.isTraceEnabled();
+        return logger.isEnabled(Level.TRACE, null, null);
     }
 
     @Override
     public boolean isTraceEnabled(final Marker marker) {
-        return logger.isTraceEnabled((org.apache.logging.log4j.Marker) marker);
+        return logger.isEnabled(Level.TRACE, (org.apache.logging.log4j.Marker) marker, null);
     }
 
     @Override
     public void trace(final Marker marker, final String s) {
-        if (isTraceEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, new SimpleMessage(s), null);
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, (org.apache.logging.log4j.Marker) marker, s);
     }
 
     @Override
     public void trace(final Marker marker, final String s, final Object o) {
-        if (isTraceEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE,
-                new ParameterizedMessage(s, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, (org.apache.logging.log4j.Marker) marker, s, o);
     }
 
     @Override
     public void trace(final Marker marker, final String s, final Object o, final Object o1) {
-        if (isTraceEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, (org.apache.logging.log4j.Marker) marker, s, o, o1);
     }
 
     @Override
     public void trace(final Marker marker, final String s, final Object... objects) {
-        if (isTraceEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, objects);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, (org.apache.logging.log4j.Marker) marker, s, objects);
     }
 
     @Override
     public void trace(final Marker marker, final String s, final Throwable throwable) {
-        if (isTraceEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE,
-                new SimpleMessage(s), throwable);
-        }
+        logger.logIfEnabled(FQCN, Level.TRACE, (org.apache.logging.log4j.Marker) marker, s, throwable);
     }
 
     @Override
     public void debug(final String format) {
-        if (logger.isDebugEnabled()) {
-            logger.log(null, FQCN, Level.DEBUG, new SimpleMessage(format), null);
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, null, format);
     }
 
     @Override
     public void debug(final String format, final Object o) {
-        if (logger.isDebugEnabled()) {
-            logger.log(null, FQCN, Level.DEBUG, new ParameterizedMessage(format, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, null, format, o);
     }
 
     @Override
     public void debug(final String format, final Object arg1, final Object arg2) {
-        if (logger.isDebugEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
-            logger.log(null, FQCN, Level.DEBUG, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, null, format, arg1, arg2);
     }
 
     @Override
     public void debug(final String format, final Object... args) {
-        if (logger.isDebugEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, args);
-            logger.log(null, FQCN, Level.DEBUG, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, null, format, args);
     }
 
     @Override
     public void debug(final String format, final Throwable t) {
-        if (logger.isDebugEnabled()) {
-            logger.log(null, FQCN, Level.DEBUG, new SimpleMessage(format), t);
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, null, format, t);
     }
 
     @Override
     public boolean isDebugEnabled() {
-        return logger.isDebugEnabled();
+        return logger.isEnabled(Level.DEBUG, null, null);
     }
 
     @Override
     public boolean isDebugEnabled(final Marker marker) {
-        return logger.isDebugEnabled((org.apache.logging.log4j.Marker) marker);
+        return logger.isEnabled(Level.DEBUG, (org.apache.logging.log4j.Marker) marker, null);
     }
 
     @Override
     public void debug(final Marker marker, final String s) {
-        if (isDebugEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, new SimpleMessage(s), null);
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, (org.apache.logging.log4j.Marker) marker, s);
     }
 
     @Override
     public void debug(final Marker marker, final String s, final Object o) {
-        if (isDebugEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG,
-                new ParameterizedMessage(s, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, (org.apache.logging.log4j.Marker) marker, s, o);
     }
 
     @Override
     public void debug(final Marker marker, final String s, final Object o, final Object o1) {
-        if (isDebugEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, (org.apache.logging.log4j.Marker) marker, s, o, o1);
     }
 
     @Override
     public void debug(final Marker marker, final String s, final Object... objects) {
-        if (isDebugEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, objects);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, (org.apache.logging.log4j.Marker) marker, s, objects);
     }
 
     @Override
     public void debug(final Marker marker, final String s, final Throwable throwable) {
-        if (isDebugEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG,
-                new SimpleMessage(s), throwable);
-        }
+        logger.logIfEnabled(FQCN, Level.DEBUG, (org.apache.logging.log4j.Marker) marker, s, throwable);
     }
 
     @Override
     public void info(final String format) {
-        if (logger.isInfoEnabled()) {
-            logger.log(null, FQCN, Level.INFO, new SimpleMessage(format), null);
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, null, format);
     }
 
     @Override
     public void info(final String format, final Object o) {
-        if (logger.isInfoEnabled()) {
-            logger.log(null, FQCN, Level.INFO, new ParameterizedMessage(format, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, null, format, o);
     }
 
     @Override
     public void info(final String format, final Object arg1, final Object arg2) {
-        if (logger.isInfoEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
-            logger.log(null, FQCN, Level.INFO, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, null, format, arg1, arg2);
     }
 
     @Override
     public void info(final String format, final Object... args) {
-        if (logger.isInfoEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, args);
-            logger.log(null, FQCN, Level.INFO, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, null, format, args);
     }
 
     @Override
     public void info(final String format, final Throwable t) {
-        if (logger.isInfoEnabled()) {
-            logger.log(null, FQCN, Level.INFO, new SimpleMessage(format), t);
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, null, format, t);
     }
 
     @Override
     public boolean isInfoEnabled() {
-        return logger.isInfoEnabled();
+        return logger.isEnabled(Level.INFO, null, null);
     }
 
     @Override
     public boolean isInfoEnabled(final Marker marker) {
-        return logger.isInfoEnabled((org.apache.logging.log4j.Marker) marker);
+        return logger.isEnabled(Level.INFO, (org.apache.logging.log4j.Marker) marker, null);
     }
 
     @Override
     public void info(final Marker marker, final String s) {
-        if (isInfoEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, new SimpleMessage(s), null);
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, (org.apache.logging.log4j.Marker) marker, s);
     }
 
     @Override
     public void info(final Marker marker, final String s, final Object o) {
-        if (isInfoEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO,
-                new ParameterizedMessage(s, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, (org.apache.logging.log4j.Marker) marker, s, o);
     }
 
     @Override
     public void info(final Marker marker, final String s, final Object o, final Object o1) {
-        if (isInfoEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, (org.apache.logging.log4j.Marker) marker, s, o, o1);
     }
 
     @Override
     public void info(final Marker marker, final String s, final Object... objects) {
-        if (isInfoEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, objects);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, (org.apache.logging.log4j.Marker) marker, s, objects);
     }
 
     @Override
     public void info(final Marker marker, final String s, final Throwable throwable) {
-        if (isInfoEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO,
-                new SimpleMessage(s), throwable);
-        }
+        logger.logIfEnabled(FQCN, Level.INFO, (org.apache.logging.log4j.Marker) marker, s, throwable);
     }
 
     @Override
     public void warn(final String format) {
-        if (logger.isWarnEnabled()) {
-            logger.log(null, FQCN, Level.WARN, new SimpleMessage(format), null);
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, null, format);
     }
 
     @Override
     public void warn(final String format, final Object o) {
-        if (logger.isWarnEnabled()) {
-            logger.log(null, FQCN, Level.WARN, new ParameterizedMessage(format, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, null, format, o);
     }
 
     @Override
     public void warn(final String format, final Object arg1, final Object arg2) {
-        if (logger.isWarnEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
-            logger.log(null, FQCN, Level.WARN, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, null, format, arg1, arg2);
     }
 
     @Override
     public void warn(final String format, final Object... args) {
-        if (logger.isWarnEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, args);
-            logger.log(null, FQCN, Level.WARN, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, null, format, args);
     }
 
     @Override
     public void warn(final String format, final Throwable t) {
-        if (logger.isWarnEnabled()) {
-            logger.log(null, FQCN, Level.WARN, new SimpleMessage(format), t);
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, null, format, t);
     }
 
     @Override
     public boolean isWarnEnabled() {
-        return logger.isWarnEnabled();
+        return logger.isEnabled(Level.WARN, null, null);
     }
 
     @Override
     public boolean isWarnEnabled(final Marker marker) {
-        return logger.isWarnEnabled((org.apache.logging.log4j.Marker) marker);
+        return logger.isEnabled(Level.WARN, (org.apache.logging.log4j.Marker) marker, null);
     }
 
     @Override
     public void warn(final Marker marker, final String s) {
-        if (isWarnEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, new SimpleMessage(s), null);
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, (org.apache.logging.log4j.Marker) marker, s);
     }
 
     @Override
     public void warn(final Marker marker, final String s, final Object o) {
-        if (isWarnEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN,
-                new ParameterizedMessage(s, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, (org.apache.logging.log4j.Marker) marker, s, o);
     }
 
     @Override
     public void warn(final Marker marker, final String s, final Object o, final Object o1) {
-        if (isWarnEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, (org.apache.logging.log4j.Marker) marker, s, o, o1);
     }
 
     @Override
     public void warn(final Marker marker, final String s, final Object... objects) {
-        if (isWarnEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, objects);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, (org.apache.logging.log4j.Marker) marker, s, objects);
     }
 
     @Override
     public void warn(final Marker marker, final String s, final Throwable throwable) {
-        if (isWarnEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN,
-                new SimpleMessage(s), throwable);
-        }
+        logger.logIfEnabled(FQCN, Level.WARN, (org.apache.logging.log4j.Marker) marker, s, throwable);
     }
 
     @Override
     public void error(final String format) {
-        if (logger.isErrorEnabled()) {
-            logger.log(null, FQCN, Level.ERROR, new SimpleMessage(format), null);
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, null, format);
     }
 
     @Override
     public void error(final String format, final Object o) {
-        if (logger.isErrorEnabled()) {
-            logger.log(null, FQCN, Level.ERROR, new ParameterizedMessage(format, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, null, format, o);
     }
 
     @Override
     public void error(final String format, final Object arg1, final Object arg2) {
-        if (logger.isErrorEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
-            logger.log(null, FQCN, Level.ERROR, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, null, format, arg1, arg2);
     }
 
     @Override
     public void error(final String format, final Object... args) {
-        if (logger.isErrorEnabled()) {
-            final ParameterizedMessage msg = new ParameterizedMessage(format, args);
-            logger.log(null, FQCN, Level.ERROR, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, null, format, args);
     }
 
     @Override
     public void error(final String format, final Throwable t) {
-        if (logger.isErrorEnabled()) {
-            logger.log(null, FQCN, Level.ERROR, new SimpleMessage(format), t);
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, null, format, t);
     }
 
     @Override
     public boolean isErrorEnabled() {
-        return logger.isErrorEnabled();
+        return logger.isEnabled(Level.ERROR, null, null);
     }
 
     @Override
     public boolean isErrorEnabled(final Marker marker) {
-        return logger.isErrorEnabled((org.apache.logging.log4j.Marker) marker);
+        return logger.isEnabled(Level.ERROR, (org.apache.logging.log4j.Marker) marker, null);
     }
 
     @Override
     public void error(final Marker marker, final String s) {
-        if (isErrorEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, new SimpleMessage(s), null);
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, (org.apache.logging.log4j.Marker) marker, s);
     }
 
     @Override
     public void error(final Marker marker, final String s, final Object o) {
-        if (isErrorEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR,
-                new ParameterizedMessage(s, o), null);
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, (org.apache.logging.log4j.Marker) marker, s, o);
     }
 
     @Override
     public void error(final Marker marker, final String s, final Object o, final Object o1) {
-        if (isErrorEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, (org.apache.logging.log4j.Marker) marker, s, o, o1);
     }
 
     @Override
     public void error(final Marker marker, final String s, final Object... objects) {
-        if (isErrorEnabled(marker)) {
-            final ParameterizedMessage msg = new ParameterizedMessage(s, objects);
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, msg, msg.getThrowable());
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, (org.apache.logging.log4j.Marker) marker, s, objects);
     }
 
     @Override
     public void error(final Marker marker, final String s, final Throwable throwable) {
-        if (isErrorEnabled(marker)) {
-            logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR,
-                new SimpleMessage(s), throwable);
-        }
+        logger.logIfEnabled(FQCN, Level.ERROR, (org.apache.logging.log4j.Marker) marker, s, throwable);
     }
 
-
     @Override
-    public void log(final Marker marker, final String fqcn, final int i, final String s1, final Object[] objects,
-                    Throwable throwable) {
-        if (!logger.isEnabled(getLevel(i), (org.apache.logging.log4j.Marker) marker, s1)) {
+    public void log(final Marker marker, final String fqcn, final int level, final String message, final Object[] params, Throwable throwable) {
+        final Level log4jLevel = getLevel(level);
+        final org.apache.logging.log4j.Marker log4jMarker = (org.apache.logging.log4j.Marker) marker;
+        
+        if (!logger.isEnabled(log4jLevel, log4jMarker, message, params)) {
             return;
         }
         Message msg;
         if (eventLogger && marker != null && marker.contains(EVENT_MARKER) && converter != null) {
-            msg = converter.convertEvent(s1, objects, throwable);
-       } else if (objects == null) {
-            msg = new SimpleMessage(s1);
+            msg = converter.convertEvent(message, params, throwable);
+        } else if (params == null) {
+            msg = new SimpleMessage(message);
         } else {
-            msg = new ParameterizedMessage(s1, objects, throwable);
+            msg = new ParameterizedMessage(message, params, throwable);
             if (throwable != null) {
                 throwable = msg.getThrowable();
             }
         }
-        logger.log((org.apache.logging.log4j.Marker) marker, fqcn, getLevel(i), msg, throwable);
+        logger.logMessage(fqcn, log4jLevel, log4jMarker, msg, throwable);
     }
 
     @Override
@@ -510,23 +381,21 @@ public class SLF4JLogger implements Loca
     }
 
     /**
-     * Always treat de-serialization as a full-blown constructor, by
-     * validating the final state of the de-serialized object.
+     * Always treat de-serialization as a full-blown constructor, by validating the final state of
+     * the de-serialized object.
      */
     private void readObject(ObjectInputStream aInputStream) throws ClassNotFoundException, IOException {
-        //always perform the default de-serialization first
+        // always perform the default de-serialization first
         aInputStream.defaultReadObject();
-        logger = new AbstractLoggerWrapper((AbstractLogger) LogManager.getLogger(name), name, null);
+        logger = LogManager.getContext().getLogger(name);
         converter = createConverter();
     }
 
     /**
-     * This is the default implementation of writeObject.
-     * Customise if necessary.
+     * This is the default implementation of writeObject. Customise if necessary.
      */
-    private void writeObject(ObjectOutputStream aOutputStream
-    ) throws IOException {
-        //perform the default serialization for all non-transient, non-static fields
+    private void writeObject(ObjectOutputStream aOutputStream) throws IOException {
+        // perform the default serialization for all non-transient, non-static fields
         aOutputStream.defaultWriteObject();
     }
 
@@ -541,16 +410,16 @@ public class SLF4JLogger implements Loca
 
     private Level getLevel(final int i) {
         switch (i) {
-            case TRACE_INT :
-                return Level.TRACE;
-            case DEBUG_INT :
-                return Level.DEBUG;
-            case INFO_INT :
-                return Level.INFO;
-            case WARN_INT :
-                return Level.WARN;
-            case ERROR_INT :
-                return Level.ERROR;
+        case TRACE_INT:
+            return Level.TRACE;
+        case DEBUG_INT:
+            return Level.DEBUG;
+        case INFO_INT:
+            return Level.INFO;
+        case WARN_INT:
+            return Level.WARN;
+        case ERROR_INT:
+            return Level.ERROR;
         }
         return Level.ERROR;
     }

Modified: logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLogger.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLogger.java (original)
+++ logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLogger.java Sun Mar 23 04:50:14 2014
@@ -18,8 +18,8 @@ package org.apache.logging.log4j.taglib;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.spi.AbstractLogger;
 import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
+import org.apache.logging.log4j.spi.LoggerProvider;
 
 /**
  * The bridge between the tag library and the Log4j API ensures that the source information for log events is
@@ -30,7 +30,7 @@ import org.apache.logging.log4j.spi.Abst
 class Log4jTaglibLogger extends AbstractLoggerWrapper {
     private static final long serialVersionUID = 1L;
 
-    public Log4jTaglibLogger(final AbstractLogger logger, final String name, final MessageFactory messageFactory) {
+    public Log4jTaglibLogger(final LoggerProvider logger, final String name, final MessageFactory messageFactory) {
         super(logger, name, messageFactory);
     }
 

Modified: logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java (original)
+++ logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java Sun Mar 23 04:50:14 2014
@@ -20,11 +20,10 @@ import java.util.WeakHashMap;
 import javax.servlet.ServletContext;
 
 import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LoggingException;
 import org.apache.logging.log4j.message.MessageFactory;
 import org.apache.logging.log4j.spi.AbstractLogger;
 import org.apache.logging.log4j.spi.LoggerContext;
+import org.apache.logging.log4j.spi.LoggerProvider;
 
 /**
  * This bridge between the tag library and the Log4j API ensures that instances of {@link Log4jTaglibLogger} are
@@ -68,15 +67,11 @@ final class Log4jTaglibLoggerContext imp
         synchronized (this.loggers) {
             logger = this.loggers.get(name);
             if (logger == null) {
-                final Logger original = factory == null ?
-                        LogManager.getLogger(name) : LogManager.getLogger(name, factory);
-                if (!(original instanceof AbstractLogger)) {
-                    throw new LoggingException(
-                            "Log4j Tag Library requires base logging system to extend Log4j AbstractLogger."
-                    );
-                }
+                final LoggerContext context = LogManager.getContext(false);
+                final LoggerProvider original = factory == null ?
+                        context.getLogger(name) : context.getLogger(name, factory);
                 // wrap a logger from an underlying implementation
-                logger = new Log4jTaglibLogger((AbstractLogger) original, name, original.getMessageFactory());
+                logger = new Log4jTaglibLogger(original, name, original.getMessageFactory());
                 this.loggers.put(name, logger);
             }
         }

Modified: logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java (original)
+++ logging/log4j/log4j2/trunk/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java Sun Mar 23 04:50:14 2014
@@ -99,7 +99,7 @@ abstract class LoggingMessageTagSupport 
             final Object message = this.getMessage();
             final Throwable exception = this.getException();
             if (message instanceof Message) {
-                logger.log(marker, FQCN, level, (Message) message, exception);
+                logger.logIfEnabled(FQCN, level, marker, (Message) message, exception);
             } else if (message instanceof String) {
                 Message data;
                 if (this.attributes.size() > 0) {
@@ -107,9 +107,9 @@ abstract class LoggingMessageTagSupport 
                 } else {
                     data = logger.getMessageFactory().newMessage((String) message);
                 }
-                logger.log(marker, FQCN, level, data, exception);
+                logger.logIfEnabled(FQCN, level, marker, data, exception);
             } else {
-                logger.log(marker, FQCN, level, logger.getMessageFactory().newMessage(message), exception);
+                logger.logIfEnabled(FQCN, level, marker, logger.getMessageFactory().newMessage(message), exception);
             }
         }
 

Modified: logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java (original)
+++ logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java Sun Mar 23 04:50:14 2014
@@ -45,35 +45,34 @@ public class SLF4JLogger extends Abstrac
         this.logger = logger;
         this.locationAwareLogger = logger instanceof LocationAwareLogger ? (LocationAwareLogger) logger : null;
     }
-
+    
     @Override
-    public void log(final Marker marker, final String fqcn, final Level level, final Message data,
-                       final Throwable t) {
+    public void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) {
         if (locationAwareLogger != null) {
-            if (data instanceof LoggerNameAwareMessage) {
-                ((LoggerNameAwareMessage) data).setLoggerName(getName());
+            if (message instanceof LoggerNameAwareMessage) {
+                ((LoggerNameAwareMessage) message).setLoggerName(getName());
             }
-            locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), data.getFormattedMessage(),
-                data.getParameters(), t);
+            locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), message.getFormattedMessage(),
+                    message.getParameters(), t);
         } else {
             switch (level.getStandardLevel()) {
                 case DEBUG :
-                    logger.debug(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t);
+                    logger.debug(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t);
                     break;
                 case TRACE :
-                    logger.trace(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t);
+                    logger.trace(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t);
                     break;
                 case INFO :
-                    logger.info(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t);
+                    logger.info(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t);
                     break;
                 case WARN :
-                    logger.warn(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t);
+                    logger.warn(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t);
                     break;
                 case ERROR :
-                    logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t);
+                    logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t);
                     break;
                 default :
-                    logger.error(getMarker(marker), data.getFormattedMessage(), data.getParameters(), t);
+                    logger.error(fqcn, getMarker(marker), message.getFormattedMessage(), message.getParameters(), t);
                     break;
             }
         }
@@ -110,27 +109,27 @@ public class SLF4JLogger extends Abstrac
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final String data) {
+    public boolean isEnabled(final Level level, final Marker marker, final String data) {
         return isEnabledFor(level, marker);
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
+    public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
         return isEnabledFor(level, marker);
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
+    public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
         return isEnabledFor(level, marker);
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) {
+    public boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) {
         return isEnabledFor(level, marker);
     }
 
     @Override
-    protected boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) {
+    public boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) {
         return isEnabledFor(level, marker);
     }
 

Modified: logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java?rev=1580445&r1=1580444&r2=1580445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java (original)
+++ logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java Sun Mar 23 04:50:14 2014
@@ -22,6 +22,7 @@ import java.util.concurrent.ConcurrentMa
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.message.MessageFactory;
 import org.apache.logging.log4j.spi.LoggerContext;
+import org.apache.logging.log4j.spi.LoggerProvider;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -36,7 +37,7 @@ public class SLF4JLoggerContext implemen
     }
 
     @Override
-    public Logger getLogger(final String name) {
+    public LoggerProvider getLogger(final String name) {
         if (!loggers.containsKey(name)) {
             loggers.putIfAbsent(name, new SLF4JLogger(name, LoggerFactory.getLogger(name)));
         }
@@ -44,7 +45,7 @@ public class SLF4JLoggerContext implemen
     }
 
     @Override
-    public Logger getLogger(final String name, final MessageFactory messageFactory) {
+    public LoggerProvider getLogger(final String name, final MessageFactory messageFactory) {
         if (!loggers.containsKey(name)) {
             loggers.putIfAbsent(name, new SLF4JLogger(name, messageFactory, LoggerFactory.getLogger(name)));
         }



Mime
View raw message