logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1125875 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers: ./ log4j12-api/src/main/java/org/apache/log4j/ log4j2-api/src/main/java/org/apache/logging/log4j/spi/ log4j2-api/src/test/java/org/apache/logging/log4j/ log4j2-core/src/m...
Date Sun, 22 May 2011 07:30:45 GMT
Author: rgoers
Date: Sun May 22 07:30:44 2011
New Revision: 1125875

URL: http://svn.apache.org/viewvc?rev=1125875&view=rev
Log:
Add support for Commons Logging. Cause SLF4J and JCL adapters to share  base Logger Context

Added:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerFactory.java
      - copied, changed from r1074871, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerFactory.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/log4j2-jcl.iml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/pom.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/META-INF/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/META-INF/services/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/resources/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java
      - copied, changed from r1074871, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggingException.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java
Removed:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerFactory.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/Log4JLogger.java
Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ListAppender.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml
    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/slf4j-impl/src/test/resources/log4j-test1.xml

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java?rev=1125875&r1=1125874&r2=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java Sun May 22 07:30:44 2011
@@ -19,8 +19,6 @@ package org.apache.log4j;
 
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.LoggerFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
 import org.apache.logging.log4j.core.helpers.NameUtil;
 import org.apache.logging.log4j.message.LocalizedMessage;
 import org.apache.logging.log4j.message.Message;
@@ -267,7 +265,7 @@ public class Category {
         }
     }
 
-    protected LoggerFactory getFactory() {
+    protected org.apache.logging.log4j.spi.LoggerFactory getFactory() {
         return FACTORY;
     }
 
@@ -278,7 +276,7 @@ public class Category {
         }
     }
 
-    private static class CategoryFactory implements LoggerFactory {
+    private static class CategoryFactory implements org.apache.logging.log4j.spi.LoggerFactory<LoggerContext> {
 
         public org.apache.logging.log4j.core.Logger newInstance(LoggerContext ctx, String name) {
             return new CategoryLogger(ctx, name);

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java Sun May 22 07:30:44 2011
@@ -0,0 +1,81 @@
+/*
+ * 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.spi;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.message.Message;
+
+/**
+ * Wrapper class that exposes the protected AbstractLogger methods to support wrapped loggers.
+ */
+public class AbstractLoggerWrapper extends AbstractLogger {
+
+    protected final AbstractLogger logger;
+    protected final String name;
+
+    public AbstractLoggerWrapper(AbstractLogger logger, String name) {
+        this.logger = logger;
+        this.name = name;
+    }
+
+    @Override
+    public void log(Marker marker, String fqcn, Level level, Message data, Throwable t) {
+        logger.log(marker, fqcn, level, data, t);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, String data) {
+        return logger.isEnabled(level, marker, data);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, String data, Throwable t) {
+        return logger.isEnabled(level, marker, data, t);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, String data, Object p1) {
+        return logger.isEnabled(level, marker, data, p1);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2) {
+        return logger.isEnabled(level, marker, data, p1, p2);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2, Object p3) {
+        return logger.isEnabled(level, marker, data, p1, p2, p3);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2, Object p3,
+                                Object... params) {
+        return logger.isEnabled(level, marker, data, p2, p2, p3, params);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, Object data, Throwable t) {
+        return logger.isEnabled(level, marker, data, t);
+    }
+
+    @Override
+    public boolean isEnabled(Level level, Marker marker, Message data, Throwable t) {
+        return logger.isEnabled(level, marker, data, t);
+    }
+}

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java?rev=1125875&r1=1125874&r2=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java Sun May 22 07:30:44 2011
@@ -9,6 +9,8 @@ public interface LoggerContext {
 
     Logger getLogger(String name);
 
+    Logger getLogger(LoggerFactory factory, String name);
+
     boolean hasLogger(String name);
 
     Object getExternalContext();

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerFactory.java (from r1074871, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerFactory.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerFactory.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerFactory.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerFactory.java&r1=1074871&r2=1125875&rev=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerFactory.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerFactory.java Sun May 22 07:30:44 2011
@@ -1,9 +1,11 @@
-package org.apache.logging.log4j.core;
+package org.apache.logging.log4j.spi;
+
+import org.apache.logging.log4j.Logger;
 
 /**
  *
  */
-public interface LoggerFactory {
+public interface LoggerFactory<C extends LoggerContext> {
 
-    Logger newInstance(LoggerContext ctx, String name);
+    Logger newInstance(C ctx, String name);
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java?rev=1125875&r1=1125874&r2=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java Sun May 22 07:30:44 2011
@@ -17,6 +17,7 @@
 package org.apache.logging.log4j;
 
 import org.apache.logging.log4j.spi.LoggerContext;
+import org.apache.logging.log4j.spi.LoggerFactory;
 
 /**
  *
@@ -35,4 +36,8 @@ public class SimpleLoggerContext impleme
     public Object getExternalContext() {
         return null;
     }
+
+    public Logger getLogger(LoggerFactory factory, String name) {
+        return factory.newInstance(this, name);
+    }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.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/LoggerContext.java?rev=1125875&r1=1125874&r2=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java Sun May 22 07:30:44 2011
@@ -18,9 +18,8 @@ package org.apache.logging.log4j.core;
 
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.apache.logging.log4j.core.config.XMLConfiguration;
 import org.apache.logging.log4j.internal.StatusLogger;
+import org.apache.logging.log4j.spi.LoggerFactory;
 
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -42,7 +41,7 @@ public class LoggerContext implements or
 
     private static StatusLogger logger = StatusLogger.getLogger();
 
-    private static final LoggerFactory FACTORY = new Factory();
+    private static final LoggerFactory<LoggerContext> FACTORY = new Factory();
 
     private Object externalContext = null;
 
@@ -68,7 +67,7 @@ public class LoggerContext implements or
             return logger;
         }
 
-        logger = factory.newInstance(this, name);
+        logger = (Logger) factory.newInstance(this, name);
         Logger prev = loggers.putIfAbsent(name, logger);
         return prev == null ? logger : prev;
     }
@@ -128,7 +127,7 @@ public class LoggerContext implements or
         }
     }
 
-    private static class Factory implements LoggerFactory {
+    private static class Factory implements LoggerFactory<LoggerContext> {
 
         public Logger newInstance(LoggerContext ctx, String name) {
             return new Logger(ctx, name);

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ListAppender.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/appender/ListAppender.java?rev=1125875&r1=1125874&r2=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ListAppender.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ListAppender.java Sun May 22 07:30:44 2011
@@ -17,6 +17,7 @@
 package org.apache.logging.log4j.core.appender;
 
 import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginAttr;
@@ -37,28 +38,41 @@ public class ListAppender extends Append
 
     private List<LogEvent> events = new ArrayList<LogEvent>();
 
+    private List<String> messages = new ArrayList<String>();
+
     public ListAppender(String name) {
         super(name, null, null);
     }
 
-    public ListAppender(String name, Filters filters) {
-        super(name, filters, null);
+    public ListAppender(String name, Filters filters, Layout layout) {
+        super(name, filters, layout);
     }
 
     public synchronized void append(LogEvent event) {
-        events.add(event);
+        Layout layout = getLayout();
+        if (layout == null) {
+            events.add(event);
+        } else {
+            messages.add(new String(layout.format(event)));
+        }
     }
 
     public synchronized void clear() {
         events.clear();
+        messages.clear();
     }
 
     public synchronized List<LogEvent> getEvents() {
         return Collections.unmodifiableList(events);
     }
 
+    public synchronized List<String> getMessages() {
+        return Collections.unmodifiableList(messages);
+    }
+
     @PluginFactory
     public static ListAppender createAppender(@PluginAttr("name") String name,
+                                              @PluginElement("layout") Layout layout,
                                               @PluginElement("filters") Filters filters) {
 
         if (name == null) {
@@ -66,6 +80,6 @@ public class ListAppender extends Append
             return null;
         }
 
-        return new ListAppender(name, filters);
+        return new ListAppender(name, filters, layout);
     }
 }

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/log4j2-jcl.iml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/log4j2-jcl.iml?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/log4j2-jcl.iml (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/log4j2-jcl.iml Sun May 22 07:30:44 2011
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.3.1" level="project" />
+    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
+    <orderEntry type="module" module-name="log4j2-core" />
+    <orderEntry type="module" module-name="log4j2-api" />
+  </component>
+</module>
+

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/pom.xml?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/pom.xml (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/pom.xml Sun May 22 07:30:44 2011
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>log4j2-rgoers</artifactId>
+    <groupId>org.apache.logging</groupId>
+    <version>1.99.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.logging</groupId>
+  <artifactId>log4j2-jcl</artifactId>
+  <version>1.99.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>Log4J2 Commons Logging</name>
+  <description>Log4j2 Commons Logging Adapter</description>
+  <url>http://logging.apache.org/log4j/experimental</url>
+
+  <dependencies>
+     <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.3.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging</groupId>
+      <artifactId>log4j2-core</artifactId>
+    </dependency>
+  </dependencies>
+
+
+</project>
\ No newline at end of file

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java Sun May 22 07:30:44 2011
@@ -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.jcl;
+
+import org.apache.commons.logging.Log;
+import org.apache.logging.log4j.spi.AbstractLogger;
+import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
+
+/**
+ *
+ */
+public class Log4JLog extends AbstractLoggerWrapper implements Log {
+
+    public Log4JLog(AbstractLogger logger, String name) {
+        super(logger, name);
+    }
+}

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java Sun May 22 07:30:44 2011
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.jcl;
+
+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 java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ *
+ */
+public class LogFactoryImpl extends LogFactory {
+
+    private static LoggerContext context = LogManager.getContext();
+
+    private ConcurrentMap<String, Log> loggers = new ConcurrentHashMap<String, Log>();
+
+    private ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();
+
+    public static LoggerContext getContext() {
+        return context;
+    }
+
+    public Log getInstance(String name) throws LogConfigurationException {
+        if (loggers.containsKey(name)) {
+            return loggers.get(name);
+        }
+        org.apache.logging.log4j.Logger logger = context.getLogger(name);
+        if (logger instanceof AbstractLogger) {
+            loggers.putIfAbsent(name, new Log4JLog((AbstractLogger) logger, name));
+            return loggers.get(name);
+        }
+        throw new LogConfigurationException("SLF4J Adapter requires base logging system to extend Log4J AbstractLogger");
+    }
+
+    @Override
+    public Object getAttribute(String name) {
+        return attributes.get(name);
+    }
+
+    @Override
+    public String[] getAttributeNames() {
+        return attributes.keySet().toArray(new String[attributes.size()]);
+    }
+
+    @Override
+    public Log getInstance(Class clazz) throws LogConfigurationException {
+        return getInstance(clazz.getName());
+    }
+
+    /**
+     * This method is supposed to clear all loggers. In this implementation it will clear all the logger
+     * wrappers but the loggers managed by the underlying logger context will not be.
+     */
+    @Override
+    public void release() {
+        loggers.clear();
+    }
+
+    @Override
+    public void removeAttribute(String name) {
+        attributes.remove(name);
+    }
+
+    @Override
+    public void setAttribute(String name, Object value) {
+        attributes.put(name, value);
+    }
+
+
+
+}

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory Sun May 22 07:30:44 2011
@@ -0,0 +1 @@
+org.apache.logging.log4j.jcl.LogFactoryImpl
\ No newline at end of file

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java Sun May 22 07:30:44 2011
@@ -0,0 +1,85 @@
+/*
+ * 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.ListAppender;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
+import org.apache.logging.log4j.internal.StatusLogger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ */
+public class LoggerTest {
+
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @BeforeClass
+    public static void setupClass() {
+        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        LoggerContext ctx = (LoggerContext) LogFactoryImpl.getContext();
+        Configuration config = ctx.getConfiguration();
+    }
+
+    @AfterClass
+    public static void cleanupClass() {
+        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        LoggerContext ctx = (LoggerContext) LogFactoryImpl.getContext();
+        ctx.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    Log logger = LogFactory.getLog("LoggerTest");
+
+    @Test
+    public void testLog() {
+        logger.debug("Test message");
+        verify("List", "o.a.l.l.j.LoggerTest Test message MDC{}\n");
+        logger.debug("Exception: " , new NullPointerException("Test"));
+        verify("List", "o.a.l.l.j.LoggerTest Exception:  MDC{}\n");
+        logger.info("Info Message");
+        verify("List", "o.a.l.l.j.LoggerTest Info Message MDC{}\n");
+    }
+
+    private void verify(String name, String expected) {
+        LoggerContext ctx = (LoggerContext) LogFactoryImpl.getContext();
+        Map<String, Appender> list = ctx.getConfiguration().getAppenders();
+        Appender listApp = list.get(name);
+        assertNotNull("Missing Appender", listApp);
+        assertTrue("Not a ListAppender", listApp instanceof ListAppender);
+        List<String> events = ((ListAppender) listApp).getMessages();
+        assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
+        String actual = events.get(0);
+        assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
+        ((ListAppender) listApp).clear();
+    }
+
+}

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml Sun May 22 07:30:44 2011
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration packages="" status="debug" name="LoggerTest">
+  <properties>
+    <property name="filename">target/test.log</property>
+  </properties>
+  <filters>
+    <Threshold level="trace"/>
+  </filters>
+
+  <appenders>
+    <List name="EventLogger">
+      <PatternLayout pattern="%C{1.} %m%n"/>
+    </List>
+    <Console name="STDOUT">
+      <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
+    </Console>
+    <File name="File" fileName="${filename}">
+      <PatternLayout>
+        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
+      </PatternLayout>
+    </File>
+    <List name="List">
+      <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
+    </List>
+  </appenders>
+
+  <loggers>
+    <logger name="EventLogger" level="info" additivity="false">
+      <appender-ref ref="EventLogger"/>
+    </logger>>
+
+    <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
+      <appender-ref ref="File"/>
+    </logger>>
+
+    <root level="trace">
+      <appender-ref ref="List"/>
+    </root>
+  </loggers>
+
+</configuration>
\ No newline at end of file

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml?rev=1125875&r1=1125874&r2=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml Sun May 22 07:30:44 2011
@@ -209,5 +209,6 @@
     <module>log4j12-api</module>
     <module>log4j2-core</module>
     <module>slf4j-impl</module>
+    <module>log4j2-jcl</module>
   </modules>
 </project>

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java (from r1074871, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggingException.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggingException.java&r1=1074871&r2=1125875&rev=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggingException.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java Sun May 22 07:30:44 2011
@@ -14,26 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core;
+package org.apache.logging.slf4j;
 
 /**
- * Exception thrown when a exception occurs while logging.  In most cases exceptions will be handled
- * within Log4j but certain Appenders may be configured to allow exceptions to propagate to the
- * application. This is a RuntimeException so that the exception may be thrown in those cases without
- * requiring all Logger methods be contained with try/catch blocks.
+ * Exception thrown when the SLF4J apapter encounters a problem.
  *
  */
-public class LoggingException extends RuntimeException {
+public class SLF4JLoggingException extends RuntimeException {
 
-    public LoggingException(String msg) {
+    public SLF4JLoggingException(String msg) {
         super(msg);
     }
 
-    public LoggingException(String msg, Exception ex) {
+    public SLF4JLoggingException(String msg, Exception ex) {
         super(msg, ex);
     }
 
-    public LoggingException(Exception ex) {
+    public SLF4JLoggingException(Exception ex) {
         super(ex);
     }
 }

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=1125875&r1=1125874&r2=1125875&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 May 22 07:30:44 2011
@@ -16,42 +16,39 @@
  */
 package org.slf4j.helpers;
 
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.LoggerFactory;
+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.slf4j.ILoggerFactory;
 import org.slf4j.Logger;
-import org.slf4j.impl.Log4JLogger;
+import org.slf4j.impl.SLF4JLogger;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 /**
  *
  */
 public class Log4JLoggerFactory implements ILoggerFactory {
 
-    private static LoggerContext ctx = new Log4JContext();
+    private static LoggerContext context = LogManager.getContext();
 
-    public Logger getLogger(String s) {
-        return (Logger) ctx.getLogger(s);
-    }
+    private ConcurrentMap<String, Logger> loggers = new ConcurrentHashMap<String, Logger>();
 
     public static LoggerContext getContext() {
-        return ctx;    
+        return context;
     }
 
-    private static class Log4JContext extends LoggerContext {
-
-        private static LoggerFactory loggerFactory = new Factory();
-
-        @Override
-        public org.apache.logging.log4j.core.Logger getLogger(String name) {
-            return getLogger(loggerFactory, name);
+    public Logger getLogger(String name) {
+        if (loggers.containsKey(name)) {
+            return loggers.get(name);
         }
-
-    }
-
-    private static class Factory implements LoggerFactory {
-
-        public org.apache.logging.log4j.core.Logger newInstance(LoggerContext ctx, String name) {
-            return new Log4JLogger(ctx, name);
+        org.apache.logging.log4j.Logger logger = context.getLogger(name);
+        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");
     }
 }

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java?rev=1125875&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java Sun May 22 07:30:44 2011
@@ -0,0 +1,372 @@
+/*
+ * 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.slf4j.impl;
+
+import org.apache.logging.log4j.Level;
+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.message.StructuredDataMessage;
+import org.apache.logging.log4j.spi.AbstractLogger;
+import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+import org.slf4j.ext.EventData;
+import org.slf4j.spi.LocationAwareLogger;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public class SLF4JLogger extends AbstractLoggerWrapper implements LocationAwareLogger {
+
+    private static final String FQCN = SLF4JLogger.class.getName();
+    private static Marker EVENT_MARKER = MarkerFactory.getMarker("EVENT");
+    private final boolean eventLogger;
+
+    public SLF4JLogger(AbstractLogger logger, String name) {
+        super(logger, name);
+        eventLogger = "EventLogger".equals(name);
+    }
+
+    @Override
+    public void trace(String format) {
+        if (isTraceEnabled()) {
+            log(null, FQCN, Level.TRACE, new SimpleMessage(format), null);
+        }
+    }
+
+    public void trace(String format, Object o) {
+        if (isTraceEnabled()) {
+            log(null, FQCN, Level.TRACE, new ParameterizedMessage(format, o), null);
+        }
+    }
+
+    public void trace(String format, Object arg1, Object arg2) {
+        if (isTraceEnabled()) {
+            log(null, FQCN, Level.TRACE, new ParameterizedMessage(format, arg1, arg2), null);
+        }
+    }
+
+    public boolean isTraceEnabled(Marker marker) {
+        return logger.isTraceEnabled((org.apache.logging.log4j.Marker) marker);
+    }
+
+    public void trace(Marker marker, String s) {
+        if (isTraceEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, new SimpleMessage(s), null);
+        }
+    }
+
+    public void trace(Marker marker, String s, Object o) {
+        if (isTraceEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, new ParameterizedMessage(s, o), null);
+        }
+    }
+
+    public void trace(Marker marker, String s, Object o, Object o1) {
+        if (isTraceEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, new ParameterizedMessage(s, o, o1), null);
+        }
+    }
+
+    public void trace(Marker marker, String s, Object[] objects) {
+        if (isTraceEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE,
+                new ParameterizedMessage(s, objects), null);
+        }
+    }
+
+    public void trace(Marker marker, String s, Throwable throwable) {
+        if (isTraceEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE,
+                new ParameterizedMessage(s, null, throwable), throwable);
+        }
+    }
+
+    @Override
+    public void debug(String format) {
+        if (isDebugEnabled()) {
+            log(null, FQCN, Level.DEBUG, new SimpleMessage(format), null);
+        }
+    }
+
+    public void debug(String format, Object o) {
+        if (isDebugEnabled()) {
+            log(null, FQCN, Level.DEBUG, new ParameterizedMessage(format, o), null);
+        }
+    }
+
+    public void debug(String format, Object arg1, Object arg2) {
+        if (isDebugEnabled()) {
+            log(null, FQCN, Level.DEBUG, new ParameterizedMessage(format, arg1, arg2), null);
+        }
+    }
+
+    public boolean isDebugEnabled(Marker marker) {
+        return logger.isDebugEnabled((org.apache.logging.log4j.Marker) marker);
+    }
+
+    public void debug(Marker marker, String s) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, new SimpleMessage(s), null);
+        }
+    }
+
+    public void debug(Marker marker, String s, Object o) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, new ParameterizedMessage(s, o), null);
+        }
+    }
+
+    public void debug(Marker marker, String s, Object o, Object o1) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, new ParameterizedMessage(s, o, o1), null);
+        }
+    }
+
+    public void debug(Marker marker, String s, Object[] objects) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG,
+                new ParameterizedMessage(s, objects), null);
+        }
+    }
+
+    public void debug(Marker marker, String s, Throwable throwable) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG,
+                new ParameterizedMessage(s, null, throwable), throwable);
+        }
+    }
+
+    @Override
+    public void info(String format) {
+        if (isInfoEnabled()) {
+            log(null, FQCN, Level.INFO, new SimpleMessage(format), null);
+        }
+    }
+
+    public void info(String format, Object o) {
+        if (isInfoEnabled()) {
+            log(null, FQCN, Level.INFO, new ParameterizedMessage(format, o), null);
+        }
+    }
+
+    public void info(String format, Object arg1, Object arg2) {
+        if (isInfoEnabled()) {
+            log(null, FQCN, Level.INFO, new ParameterizedMessage(format, arg1, arg2), null);
+        }
+    }
+
+    public boolean isInfoEnabled(Marker marker) {
+        return logger.isInfoEnabled((org.apache.logging.log4j.Marker) marker);
+    }
+
+    public void info(Marker marker, String s) {
+        if (isInfoEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, new SimpleMessage(s), null);
+        }
+    }
+
+    public void info(Marker marker, String s, Object o) {
+        if (isInfoEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, new ParameterizedMessage(s, o), null);
+        }
+    }
+
+    public void info(Marker marker, String s, Object o, Object o1) {
+        if (isInfoEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, new ParameterizedMessage(s, o, o1), null);
+        }
+    }
+
+    public void info(Marker marker, String s, Object[] objects) {
+        if (isInfoEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO,
+                new ParameterizedMessage(s, objects), null);
+        }
+    }
+
+    public void info(Marker marker, String s, Throwable throwable) {
+        if (isInfoEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO,
+                new ParameterizedMessage(s, null, throwable), throwable);
+        }
+    }
+
+    @Override
+    public void warn(String format) {
+        if (isWarnEnabled()) {
+            log(null, FQCN, Level.WARN, new SimpleMessage(format), null);
+        }
+    }
+
+    public void warn(String format, Object o) {
+        if (isWarnEnabled()) {
+            log(null, FQCN, Level.WARN, new ParameterizedMessage(format, o), null);
+        }
+    }
+
+    public void warn(String format, Object arg1, Object arg2) {
+        if (isWarnEnabled()) {
+            log(null, FQCN, Level.WARN, new ParameterizedMessage(format, arg1, arg2), null);
+        }
+    }
+
+    public boolean isWarnEnabled(Marker marker) {
+        return logger.isWarnEnabled((org.apache.logging.log4j.Marker) marker);
+    }
+
+    public void warn(Marker marker, String s) {
+        if (isWarnEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, new SimpleMessage(s), null);
+        }
+    }
+
+    public void warn(Marker marker, String s, Object o) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, new ParameterizedMessage(s, o), null);
+        }
+    }
+
+    public void warn(Marker marker, String s, Object o, Object o1) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, new ParameterizedMessage(s, o, o1), null);
+        }
+    }
+
+    public void warn(Marker marker, String s, Object[] objects) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN,
+                new ParameterizedMessage(s, objects), null);
+        }
+    }
+
+    public void warn(Marker marker, String s, Throwable throwable) {
+        if (isDebugEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN,
+                new ParameterizedMessage(s, null, throwable), throwable);
+        }
+    }
+
+    @Override
+    public void error(String format) {
+        if (isErrorEnabled()) {
+            log(null, FQCN, Level.ERROR, new SimpleMessage(format), null);
+        }
+    }
+
+    public void error(String format, Object o) {
+        if (isErrorEnabled()) {
+            log(null, FQCN, Level.ERROR, new ParameterizedMessage(format, o), null);
+        }
+    }
+
+    public void error(String format, Object arg1, Object arg2) {
+        if (isErrorEnabled()) {
+            log(null, FQCN, Level.ERROR, new ParameterizedMessage(format, arg1, arg2), null);
+        }
+    }
+
+    public boolean isErrorEnabled(Marker marker) {
+        return logger.isErrorEnabled((org.apache.logging.log4j.Marker) marker);
+    }
+
+    public void error(Marker marker, String s) {
+        if (isErrorEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, new SimpleMessage(s), null);
+        }
+    }
+
+    public void error(Marker marker, String s, Object o) {
+        if (isErrorEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, new ParameterizedMessage(s, o), null);
+        }
+    }
+
+    public void error(Marker marker, String s, Object o, Object o1) {
+        if (isErrorEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, new ParameterizedMessage(s, o, o1), null);
+        }
+    }
+
+    public void error(Marker marker, String s, Object[] objects) {
+        if (isErrorEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR,
+                new ParameterizedMessage(s, objects), null);
+        }
+    }
+
+    public void error(Marker marker, String s, Throwable throwable) {
+        if (isErrorEnabled(marker)) {
+            log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR,
+                new ParameterizedMessage(s, null, throwable), throwable);
+        }
+    }
+
+    public void log(Marker marker, String fqcn, int i, String s1, Object[] objects, Throwable throwable) {
+        Message msg;
+        if (eventLogger && marker != null && marker.contains(EVENT_MARKER)) {
+            try {
+                EventData data = (objects != null && objects[0] instanceof EventData) ? (EventData) objects[0] :
+                    new EventData(s1);
+                msg = new StructuredDataMessage(data.getEventId(), data.getMessage(), data.getEventType());
+                for (Map.Entry entry : data.getEventMap().entrySet()) {
+                    String key = entry.getKey().toString();
+                    if (EventData.EVENT_TYPE.equals(key) || EventData.EVENT_ID.equals(key) ||
+                        EventData.EVENT_MESSAGE.equals(key)) {
+                        continue;
+                    }
+                    ((StructuredDataMessage) msg).put(entry.getKey().toString(), entry.getValue().toString());
+                }
+            } catch (Exception ex) {
+                msg = new ParameterizedMessage(s1, objects, throwable);
+            }
+
+        } else {
+            msg = new ParameterizedMessage(s1, objects, throwable);
+        }
+        log((org.apache.logging.log4j.Marker) marker, fqcn, getLevel(i), msg, throwable);
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    protected String getFQCN() {
+        return FQCN;
+    }
+
+    private Level getLevel(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;
+        }
+        return Level.ERROR;
+    }
+}

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=1125875&r1=1125874&r2=1125875&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 May 22 07:30:44 2011
@@ -16,7 +16,10 @@
  */
 package org.apache.logging.slf4j;
 
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.ListAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
 import org.apache.logging.log4j.internal.StatusLogger;
@@ -32,8 +35,14 @@ import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 import org.slf4j.helpers.Log4JLoggerFactory;
 
+import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  *
@@ -45,14 +54,14 @@ public class LoggerTest {
     @BeforeClass
     public static void setupClass() {
         System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
-        LoggerContext ctx = Log4JLoggerFactory.getContext();
+        LoggerContext ctx = (LoggerContext) Log4JLoggerFactory.getContext();
         Configuration config = ctx.getConfiguration();
     }
 
     @AfterClass
     public static void cleanupClass() {
         System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-        LoggerContext ctx = Log4JLoggerFactory.getContext();
+        LoggerContext ctx = (LoggerContext) Log4JLoggerFactory.getContext();
         ctx.reconfigure();
         StatusLogger.getLogger().reset();
     }
@@ -63,18 +72,23 @@ public class LoggerTest {
     @Test
     public void basicFlow() {
         xlogger.entry();
+        verify("List", "o.a.l.s.LoggerTest entry MDC{}\n");
         xlogger.exit();
+        verify("List", "o.a.l.s.LoggerTest exit MDC{}\n");
     }
 
     @Test
     public void simpleFlow() {
         xlogger.entry(CONFIG);
+        verify("List", "o.a.l.s.LoggerTest entry with (log4j-test1.xml) MDC{}\n");
         xlogger.exit(0);
+        verify("List", "o.a.l.s.LoggerTest exit with (0) MDC{}\n");
     }
 
     @Test
     public void throwing() {
         xlogger.throwing(new IllegalArgumentException("Test Exception"));
+        verify("List", "o.a.l.s.LoggerTest throwing MDC{}\n");
     }
 
     @Test
@@ -83,18 +97,21 @@ public class LoggerTest {
             throw new NullPointerException();
         } catch (Exception e) {
             xlogger.catching(e);
+            verify("List", "o.a.l.s.LoggerTest catching MDC{}\n");
         }
     }
 
     @Test
     public void debug() {
         logger.debug("Debug message");
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}\n");
     }
 
 
     @Test
     public void debugWithParms() {
         logger.debug("Hello, {}", "World");
+        verify("List", "o.a.l.s.LoggerTest Hello, World MDC{}\n");
     }
 
     @Test
@@ -102,8 +119,10 @@ public class LoggerTest {
 
         MDC.put("TestYear", "2010");
         logger.debug("Debug message");
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}\n");
         MDC.clear();
         logger.debug("Debug message");
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}\n");
     }
 
     @Test
@@ -120,5 +139,19 @@ public class LoggerTest {
         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\n");
+    }
+
+    private void verify(String name, String expected) {
+        LoggerContext ctx = (LoggerContext) Log4JLoggerFactory.getContext();
+        Map<String, Appender> list = ctx.getConfiguration().getAppenders();
+        Appender listApp = list.get(name);
+        assertNotNull("Missing Appender", listApp);
+        assertTrue("Not a ListAppender", listApp instanceof ListAppender);
+        List<String> events = ((ListAppender) listApp).getMessages();
+        assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
+        String actual = events.get(0);
+        assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
+        ((ListAppender) listApp).clear();
     }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/resources/log4j-test1.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/resources/log4j-test1.xml?rev=1125875&r1=1125874&r2=1125875&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/resources/log4j-test1.xml (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/test/resources/log4j-test1.xml Sun May 22 07:30:44 2011
@@ -8,11 +8,11 @@
   </filters>
 
   <appenders>
-    <Console name="EventLogger">
-      <PatternLayout pattern="%m%n"/>
-    </Console>
+    <List name="EventLogger">
+      <PatternLayout pattern="%C{1.} %m%n"/>
+    </List>
     <Console name="STDOUT">
-      <PatternLayout pattern="%m MDC%X%n"/>
+      <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
     </Console>
     <File name="File" fileName="${filename}">
       <PatternLayout>
@@ -20,9 +20,7 @@
       </PatternLayout>
     </File>
     <List name="List">
-      <filters>
-        <Threshold level="error"/>
-      </filters>
+      <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
     </List>
   </appenders>
 
@@ -36,7 +34,7 @@
     </logger>>
 
     <root level="trace">
-      <appender-ref ref="STDOUT"/>
+      <appender-ref ref="List"/>
     </root>
   </loggers>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message