[slf4j-dev] svn commit: r838 - in slf4j/trunk: . log4j-over-slf4j log4j-over-slf4j/compatibility log4j-over-slf4j/compatibility/lib log4j-over-slf4j/compatibility/src log4j-over-slf4j/compatibility/src/main log4j-over-slf4j/compatibility/src/main/java log4j-over-slf4j/compatibility/src/main/java/test log4j-over-slf4j/src log4j-over-slf4j/src/main log4j-over-slf4j/src/main/java log4j-over-slf4j/src/main/java/org log4j-over-slf4j/src/main/java/org/apache log4j-over-slf4j/src/main/java/org/apache/log4j log4j-over-slf4j/src/test log4j-over-slf4j/src/test/java log4j-over-slf4j/src/test/java/org log4j-over-slf4j/src/test/java/org/apache log4j-over-slf4j/src/test/java/org/apache/log4j

ceki at slf4j.org ceki at slf4j.org
Mon Jul 9 22:24:03 CEST 2007


Author: ceki
Date: Mon Jul  9 22:24:02 2007
New Revision: 838

Added:
   slf4j/trunk/log4j-over-slf4j/
   slf4j/trunk/log4j-over-slf4j/compatibility/
   slf4j/trunk/log4j-over-slf4j/compatibility/build.xml
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/junit-3.8.1.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.2.14.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.3alpha-8.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/log4j-bridge-0.9.1.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-classic-0.9.1.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-classic-0.9.8-SNAPSHOT.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-core-0.9.1.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-core-0.9.8-SNAPSHOT.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/lib/slf4j-api-1.4.1.jar   (contents, props changed)
   slf4j/trunk/log4j-over-slf4j/compatibility/readme.txt
   slf4j/trunk/log4j-over-slf4j/compatibility/src/
   slf4j/trunk/log4j-over-slf4j/compatibility/src/main/
   slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/
   slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/test/
   slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j12Calls.java
   slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j13Calls.java
   slf4j/trunk/log4j-over-slf4j/pom.xml
   slf4j/trunk/log4j-over-slf4j/src/
   slf4j/trunk/log4j-over-slf4j/src/main/
   slf4j/trunk/log4j-over-slf4j/src/main/java/
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/BasicConfigurator.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html
   slf4j/trunk/log4j-over-slf4j/src/test/
   slf4j/trunk/log4j-over-slf4j/src/test/java/
   slf4j/trunk/log4j-over-slf4j/src/test/java/org/
   slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/
   slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/
   slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/DummyObject.java
   slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/LoggerTest.java
Modified:
   slf4j/trunk/pom.xml

Log:
- adding log4j-over-slf4j 

Added: slf4j/trunk/log4j-over-slf4j/compatibility/build.xml
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/compatibility/build.xml	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,119 @@
+<project name="testing-log4j-bridge" default="usage" basedir=".">
+
+	<property name="lbversion" value="0.9.8-SNAPSHOT" />
+  <property name="slf4jversion" value="1.4.1" />
+	<property name="source.home" value="./src/main/java/" />
+	<property name="javac.dest.12" value="./target/classes12/" />
+	<property name="javac.dest.13" value="./target/classes13/" />
+	<property name="lib" value="./lib" />
+
+	<property name="deprecation" value="on" />
+
+	<path id="basic.classpath">
+		<pathelement location="${source.home}" />
+		<pathelement location="${lib}/junit-3.8.1.jar" />
+	</path>
+
+	<path id="log4j12.classpath">
+		<path refid="basic.classpath" />
+		<pathelement location="${javac.dest.12}" />
+		<pathelement location="${lib}/log4j-1.2.14.jar" />
+	</path>
+
+	<path id="log4j13.classpath">
+		<path refid="basic.classpath" />
+		<pathelement location="${javac.dest.13}" />
+		<pathelement location="${lib}/log4j-1.3alpha-8.jar" />
+	</path>
+
+	<path id="log4-bridge.classpath">
+		<path refid="basic.classpath" />
+		<pathelement location="${lib}/log4j-bridge-${lbversion}.jar" />
+		<pathelement location="${lib}/logback-classic-${lbversion}.jar" />
+		<pathelement location="${lib}/logback-core-${lbversion}.jar" />
+		<pathelement location="${lib}/slf4j-api-${slf4jversion}.jar" />
+	</path>
+
+	<!-- ================================================================= -->
+	<!-- Default target                                                    -->
+	<!-- ================================================================= -->
+	<target name="usage">
+		<echo>      
+      These are some of the targets supported by this ANT build scpript:
+
+      all - run all available tests
+      refresh - copy required jar files to the lib directory
+    </echo>
+	</target>
+
+  <delete>
+    <fileset dir="." includes="**/*.bak"/>
+  </delete>
+
+  <target name="refresh">
+    <delete>
+      <fileset dir="lib">
+        <include name="logback-*.jar"/>
+        <include name="log4j-bridge-*.jar"/>
+      </fileset>
+    </delete>
+    <copy file="../../logback-core/target/logback-core-${lbversion}.jar" todir="lib/"/>
+    <copy file="../../logback-classic/target/logback-classic-${lbversion}.jar" todir="lib/"/>
+    <copy file="../target/log4j-bridge-${lbversion}.jar" todir="lib/"/>
+
+  </target>
+
+
+	<target name="init">
+		<mkdir dir="${javac.dest.12}" />
+		<mkdir dir="${javac.dest.13}" />
+	</target>
+
+	<target name="clean">
+		<delete>
+			<fileset dir="${javac.dest.12}" includes="**" />
+			<fileset dir="${javac.dest.13}" includes="**" />
+		</delete>
+	</target>
+
+	<target name="build_log4j12" depends="init">
+		<javac srcdir="${source.home}" 
+			     destdir="${javac.dest.12}" 
+			     includes="**/Log4j12Calls.java" 
+			     deprecation="${deprecation}" debug="on">
+			<classpath refid="log4j12.classpath" />
+		</javac>
+	</target>
+
+	<target name="build_log4j13" depends="init">
+		<javac srcdir="${source.home}" 
+			     destdir="${javac.dest.13}" 
+			     includes="**/Log4j13Calls.java" deprecation="${deprecation}" debug="on">
+			<classpath refid="log4j13.classpath" />
+		</javac>
+	</target>
+
+	<!-- ================================================================= -->
+	<!-- Run tests                                                     -->
+	<!-- ================================================================= -->
+	<target name="all" depends="test12, test13" />
+
+	<target name="test12" depends="build_log4j12">
+		<junit printsummary="yes" fork="yes" haltonfailure="yes">
+			<classpath refid="log4-bridge.classpath" />
+			<classpath location="${javac.dest.12}" />
+			<formatter type="plain" usefile="false" />
+			<test name="test.Log4j12Calls" />
+		</junit>
+	</target>
+
+	<target name="test13" depends="build_log4j13">
+		<junit printsummary="yes" fork="yes" haltonfailure="yes">
+			<classpath refid="log4-bridge.classpath" />
+			<classpath location="${javac.dest.13}" />
+			<formatter type="plain" usefile="false" />
+			<test name="test.Log4j13Calls" />
+		</junit>
+	</target>
+
+</project>

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/junit-3.8.1.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.2.14.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.3alpha-8.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/log4j-bridge-0.9.1.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-classic-0.9.1.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-classic-0.9.8-SNAPSHOT.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-core-0.9.1.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/logback-core-0.9.8-SNAPSHOT.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/lib/slf4j-api-1.4.1.jar
==============================================================================
Binary file. No diff available.

Added: slf4j/trunk/log4j-over-slf4j/compatibility/readme.txt
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/compatibility/readme.txt	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,22 @@
+#--------------------------#
+|                          |
+|   Log4j-bridge Read-me   |
+|                          |
+#--------------------------#
+
+This directory is used to test the module against various log4j calls. 
+Two test cases simulate the typical calls that one can find in an application 
+that uses either log4j 1.2.x, or log4j 1.3.x.
+
+In the same directory is a build.xml file that uses ant to 
+compile the test cases with the corresponding log4j version, 
+and to runs these tests without log4j in the classpath but with 
+logback jars instead.
+
+To run the tests, one must have ant installed. Issuing the following command, 
+once in the compatibility directory will launch the tests:
+
+ant all
+
+To obtain more information about the use of the log4j-bridge module, 
+please visit http://logback.qos.ch/bridge.html
\ No newline at end of file

Added: slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j12Calls.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j12Calls.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,39 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * 
+ * Copyright (C) 1999-2006, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package test;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.MDC;
+
+/**
+ * 
+ * A test case that issues the typical calls
+ * that an application using log4j 1.2 would do.
+ *
+ * @author Ceki G&uuml;lc&uuml;
+ * @author S&eacute;bastien Pennec
+ */
+public class Log4j12Calls extends TestCase {
+  public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
+  
+  public void testLog() {
+    MDC.put("key", "value1");
+    
+    logger.trace("Trace level can be noisy");
+    logger.debug("Entering application");
+    logger.info("Violets are blue");
+    logger.warn("Here is a warning");
+    logger.error("Exiting application", new Exception("just testing"));
+    
+    MDC.remove("key");
+  }
+}

Added: slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j13Calls.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j13Calls.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,46 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * 
+ * Copyright (C) 1999-2006, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package test;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.MDC;
+
+/**
+ * 
+ * A test case that issues the typical calls
+ * that an application using log4j 1.3 would do.
+ *
+ * @author Ceki G&uuml;lc&uuml;
+ * @author S&eacute;bastien Pennec
+ */
+
+public class Log4j13Calls extends TestCase {
+  public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
+  
+  public void testLog() {
+    MDC.put("key", "value1");
+    
+    logger.trace("Trace level can be noisy");
+    logger.debug("Entering application");
+    logger.info("Violets are blue");
+    logger.warn("Here is a warning");
+    logger.info("The answer is {}.", new Integer(42));
+    logger.info("Number: {} and another one: {}.", new Integer(42), new Integer(24));
+    
+    logger.error("Exiting application", new Exception("just testing"));
+    
+    MDC.remove("key");
+    
+    MDC.clear();
+  }
+}

Added: slf4j/trunk/log4j-over-slf4j/pom.xml
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/pom.xml	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,65 @@
+<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/maven-v4_0_0.xsd">
+
+  <parent>
+    <groupId>ch.qos.logback</groupId>
+    <artifactId>logback-parent</artifactId>
+    <version>0.9.8-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+	<groupId>org.slf4j</groupId>
+	<artifactId>log4j-over-slf4j</artifactId>
+	<version>${parent.version}</version>
+	<packaging>jar</packaging>
+	<name>Log4j Implemented Over SLF4J</name>
+
+	<url>http://www.slf4j.org</url>
+
+  <description>
+    <!-- 
+      Never _never_ let Eclipse's auto format function add
+      a line return in the description.
+      The generated jar will contain a corrupt MANIFEST file.
+    -->
+  	Log4j implemented over SLF4J
+  </description>
+  <licenses>
+    <license>
+      <name>Apache Software Licenses</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+    </license>
+  </licenses>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+		</dependency>
+  </dependencies>
+
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>bundle-test-jar</id>
+            <phase>package</phase>
+            <goals>
+              <goal>jar</goal>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+    
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/BasicConfigurator.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/BasicConfigurator.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,17 @@
+package org.apache.log4j;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+
+public class BasicConfigurator {
+
+  static public void configure() {
+    ch.qos.logback.classic.BasicConfigurator.configureDefaultContext();
+  }
+
+  public static void resetConfiguration() {
+    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+    lc.shutdownAndReset();
+  }
+}

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,381 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j;
+
+import org.slf4j.LoggerFactory;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+import org.slf4j.spi.LocationAwareLogger;
+
+import ch.qos.logback.classic.Level;
+
+/**
+ * <p>
+ * This class is a minimal implementation of the origianl
+ * org.apache.log4j.Logger class delegating all calls to a
+ * {@link org.slf4j.Logger.Logger} instance.
+ * </p>
+ * 
+ * <p>
+ * Log4j's <code>debug()</code>, <code>info()</code>, <code>warn()</code>,
+ * <code>error()</code> printing methods are directly mapped to their logback
+ * equivalents. Log4j's <code>trace()</code> printing method is mapped to
+ * logback's <code>debug()</code> method with a TRACE marker. Log4j's
+ * <code>fatal()</code> printing method is mapped to logback's
+ * <code>error()</code> method with a FATAL marker.
+ * 
+ * @author S&eacute;bastien Pennec
+ * @author Ceki G&uuml;lc&uuml;
+ */
+
+public class Category {
+
+  private String name;
+
+  private org.slf4j.Logger lbLogger;
+  private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
+  
+  private static Marker TRACE_MARKER = MarkerFactory.getMarker("TRACE");
+  private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
+
+  Category(String name) {
+    this.name = name;
+    lbLogger = LoggerFactory.getLogger(name);
+    if(lbLogger instanceof LocationAwareLogger) {
+      locationAwareLogger = (LocationAwareLogger) lbLogger;
+    }
+  }
+
+  public static Logger getLogger(String name) {
+    return Log4jLoggerFactory.getLogger(name);
+  }
+
+  public static Logger getLogger(Class clazz) {
+    return getLogger(clazz.getName());
+  }
+
+  /**
+   * Does the obvious.
+   * 
+   * @return
+   */
+  public static Logger getRootLogger() {
+    return getLogger("root");
+  }
+
+  /**
+   * Returns the obvious.
+   * 
+   * @return
+   */
+  public String getName() {
+    return name;
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#isTraceEnabled} 
+   * method of logback.
+   */
+  public boolean isTraceEnabled() {
+    return lbLogger.isTraceEnabled();
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#isDebugEnabled} method of logback
+   */
+  public boolean isDebugEnabled() {
+    return lbLogger.isDebugEnabled();
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#isInfoEnabled} method of logback
+   */
+  public boolean isInfoEnabled() {
+    return lbLogger.isInfoEnabled();
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#isWarnEnabled} method of logback
+   */
+  public boolean isWarnEnabled() {
+    return lbLogger.isWarnEnabled();
+  }
+  
+  public boolean isEnabledFor(Priority p) {
+    return isEnabledFor(Level.toLevel(p.level));
+  }
+
+  public boolean isEnabledFor(Level l) {
+    switch (l.levelInt) {
+    case Level.TRACE_INT:
+      return lbLogger.isTraceEnabled();
+    case Level.DEBUG_INT:
+      return lbLogger.isDebugEnabled();
+    case Level.INFO_INT:
+      return lbLogger.isInfoEnabled();
+    case Level.WARN_INT:
+      return lbLogger.isWarnEnabled();
+    case Level.ERROR_INT:
+      return lbLogger.isErrorEnabled();
+    case Priority.FATAL_INT:
+      return lbLogger.isErrorEnabled();
+    }
+    return false;
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#isErrorEnabled} method of logback
+   */
+  public boolean isErrorEnabled() {
+    return lbLogger.isErrorEnabled();
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String)} method of logback, 
+   * in addition, the call is marked with a marker named "TRACE".
+   */
+  public void trace(Object message) {
+    lbLogger.debug(TRACE_MARKER, convertToString(message));
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String,Throwable)} 
+   * method of logback in addition, the call is marked with a marker named "TRACE".
+   */
+  public void trace(Object message, Throwable t) {
+    lbLogger.debug(TRACE_MARKER, convertToString(message), t);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String,Object)} 
+   * method of logback in addition, the call is marked with a marker named "TRACE".
+   */
+  public void trace(Object message, Object o) {
+    lbLogger.debug(TRACE_MARKER, convertToString(message), o);
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String,Object,Object)} 
+   * method of logback in addition, the call is marked with a marker named "TRACE".
+   */
+  public void trace(String message, Object arg1, Object arg2) {
+    lbLogger.debug(TRACE_MARKER, message, arg1, arg2);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String)} method of
+   * logback.
+   */
+  public void debug(Object message) {
+    // casting to String as SLF4J only accepts String instances, not Object
+    // instances.
+    lbLogger.debug(convertToString(message));
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String,Throwable)} 
+   * method of logback.
+   */
+  public void debug(Object message, Throwable t) {
+    lbLogger.debug(convertToString(message), t);
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String,Object)} 
+   * method of logback.
+   */
+  public void debug(Object message, Object o) {
+    lbLogger.debug(convertToString(message), o);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#debug(String,Object,Object)} 
+   * method of logback.
+   */
+  public void debug(String message, Object arg1, Object arg2) {
+    lbLogger.debug(message, arg1, arg2);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#info(String)} 
+   * method of logback.
+   */
+  public void info(Object message) {
+    lbLogger.info(convertToString(message));
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#info(String,Throwable)} 
+   * method of logback.
+   */
+  public void info(Object message, Throwable t) {
+    lbLogger.info(convertToString(message), t);
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#info(String,Object)} 
+   * method of logback.
+   */
+  public void info(Object message, Object o) {
+    lbLogger.info(convertToString(message), o);
+  }  
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#info(String,Object,Object)} 
+   * method of logback.
+   */
+  public void info(String message, Object arg1, Object arg2) {
+    lbLogger.info(message, arg1, arg2);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#warn(String)} 
+   * method of logback.
+   */
+  public void warn(Object message) {
+    lbLogger.warn(convertToString(message));
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#warn(String,Throwable)} 
+   * method of logback.
+   */
+  public void warn(Object message, Throwable t) {
+    lbLogger.warn(convertToString(message), t);
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#warn(String,Object)} 
+   * method of logback.
+   */
+  public void warn(Object message, Object o) {
+    lbLogger.warn(convertToString(message), o);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#warn(String,Object,Object)} 
+   * method of logback.
+   */
+  public void warn(String message, Object arg1, Object arg2) {
+    lbLogger.warn(message, arg1, arg2);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String)} 
+   * method of logback.
+   */
+  public void error(Object message) {
+    lbLogger.error(convertToString(message));
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String,Throwable)} 
+   * method of logback.
+   */
+  public void error(Object message, Throwable t) {
+    lbLogger.error(convertToString(message), t);
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String,Object)} 
+   * method of logback.
+   */
+  public void error(Object message, Object o) {
+    lbLogger.error(convertToString(message), o);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String,Object,Object)} 
+   * method of logback.
+   */
+  public void error(String message, Object arg1, Object arg2) {
+    lbLogger.error(message, arg1, arg2);
+  }
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String)} 
+   * method of logback.
+   */
+  public void fatal(Object message) {
+    lbLogger.error(FATAL_MARKER, convertToString(message));
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String,Throwable)} 
+   * method of logback in addition, the call is marked with a marker named "FATAL".
+   */
+  public void fatal(Object message, Throwable t) {
+    lbLogger.error(FATAL_MARKER, convertToString(message), t);
+  }
+
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String,Object)} 
+   * method of logback in addition, the call is marked with a marker named "FATAL".
+   */
+  public void fatal(Object message, Object o) {
+    lbLogger.error(FATAL_MARKER, convertToString(message), o);
+  } 
+  
+  /**
+   * Delegates to {@link ch.qos.logback.classic.Logger#error(String,Object,Object)} 
+   * method of logback in addition, the call is marked with a marker named "FATAL".
+   */
+  public void fatal(String message, Object arg1, Object arg2) {
+    lbLogger.error(FATAL_MARKER, message, arg1, arg2);
+  } 
+  
+  public void log(String FQCN, Priority p, Object msg, Throwable t) {
+    int levelInt = priorityToLevelInt(p);
+    if(locationAwareLogger != null) {
+      if(msg != null) {
+        locationAwareLogger.log(null, FQCN, levelInt, msg.toString(), t); 
+      } else {
+        locationAwareLogger.log(null, FQCN, levelInt, null, t); 
+      }
+    } else {
+      throw new UnsupportedOperationException("The logger ["+lbLogger+"] does not seem to be location aware.");
+    }
+   
+  }
+  
+  private int priorityToLevelInt(Priority p) {
+    switch (p.level) {
+    case Level.TRACE_INT:
+      return LocationAwareLogger.TRACE_INT;
+    case Priority.DEBUG_INT:
+      return LocationAwareLogger.DEBUG_INT;
+    case Priority.INFO_INT:
+      return LocationAwareLogger.INFO_INT;
+    case Priority.WARN_INT:
+      return LocationAwareLogger.WARN_INT;
+    case Priority.ERROR_INT:
+      return LocationAwareLogger.ERROR_INT;
+    case Priority.FATAL_INT:
+      return LocationAwareLogger.ERROR_INT;
+    default:
+      throw new IllegalStateException("Unknown Priority " + p);
+    }
+  }
+  
+  private final String convertToString(Object message) {
+    if (message == null) {
+      return (String)message;
+    } else {
+      return message.toString();
+    }
+  }
+
+}

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,218 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+
+// Contributors:  Kitching Simon <Simon.Kitching at orange.ch>
+//                Nicholas Wolff
+
+package org.apache.log4j;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
+/**
+   Defines the minimum set of levels recognized by the system, that is
+   <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
+   <code>WARN</code>, <code>INFO</code, <code>DEBUG</code> and
+   <code>ALL</code>.
+
+   <p>The <code>Level</code> class may be subclassed to define a larger
+   level set.
+
+   @author Ceki G&uuml;lc&uuml;
+
+ */
+public class Level extends Priority implements Serializable {
+
+   /**
+    * TRACE level integer value.
+    * @since 1.2.12
+    */
+  public static final int TRACE_INT = 5000;
+
+  /**
+     The <code>OFF</code> has the highest possible rank and is
+     intended to turn off logging.  */
+  final static public Level OFF = new Level(OFF_INT, "OFF", 0);
+
+  /**
+     The <code>FATAL</code> level designates very severe error
+     events that will presumably lead the application to abort.
+   */
+  final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
+
+  /**
+     The <code>ERROR</code> level designates error events that
+     might still allow the application to continue running.  */
+  final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
+
+  /**
+     The <code>WARN</code> level designates potentially harmful situations.
+  */
+  final static public Level WARN  = new Level(WARN_INT, "WARN",  4);
+
+  /**
+     The <code>INFO</code> level designates informational messages
+     that highlight the progress of the application at coarse-grained
+     level.  */
+  final static public Level INFO  = new Level(INFO_INT, "INFO",  6);
+
+  /**
+     The <code>DEBUG</code> Level designates fine-grained
+     informational events that are most useful to debug an
+     application.  */
+  final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
+
+  /**
+    * The <code>TRACE</code> Level designates finer-grained
+    * informational events than the <code>DEBUG</code level.
+   *  @since 1.2.12
+    */
+  public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
+
+
+  /**
+     The <code>ALL</code> has the lowest possible rank and is intended to
+     turn on all logging.  */
+  final static public Level ALL = new Level(ALL_INT, "ALL", 7);
+
+  /**
+   * Serialization version id.
+   */
+  static final long serialVersionUID = 3491141966387921974L;
+
+  /**
+     Instantiate a Level object.
+   */
+  protected
+  Level(int level, String levelStr, int syslogEquivalent) {
+    super(level, levelStr, syslogEquivalent);
+  }
+
+
+  /**
+     Convert the string passed as argument to a level. If the
+     conversion fails, then this method returns {@link #DEBUG}. 
+  */
+  public
+  static
+  Level toLevel(String sArg) {
+    return (Level) toLevel(sArg, Level.DEBUG);
+  }
+
+  /**
+    Convert an integer passed as argument to a level. If the
+    conversion fails, then this method returns {@link #DEBUG}.
+
+  */
+  public
+  static
+  Level toLevel(int val) {
+    return (Level) toLevel(val, Level.DEBUG);
+  }
+
+  /**
+    Convert an integer passed as argument to a level. If the
+    conversion fails, then this method returns the specified default.
+  */
+  public
+  static
+  Level toLevel(int val, Level defaultLevel) {
+    switch(val) {
+    case ALL_INT: return ALL;
+    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 FATAL_INT: return Level.FATAL;
+    case OFF_INT: return OFF;
+    case TRACE_INT: return Level.TRACE;
+    default: return defaultLevel;
+    }
+  }
+
+  /**
+     Convert the string passed as argument to a level. If the
+     conversion fails, then this method returns the value of
+     <code>defaultLevel</code>.  
+  */
+  public
+  static
+  Level toLevel(String sArg, Level defaultLevel) {                  
+    if(sArg == null)
+       return defaultLevel;
+    
+    String s = sArg.toUpperCase();
+
+    if(s.equals("ALL")) return Level.ALL; 
+    if(s.equals("DEBUG")) return Level.DEBUG; 
+    if(s.equals("INFO"))  return Level.INFO;
+    if(s.equals("WARN"))  return Level.WARN;  
+    if(s.equals("ERROR")) return Level.ERROR;
+    if(s.equals("FATAL")) return Level.FATAL;
+    if(s.equals("OFF")) return Level.OFF;
+    if(s.equals("TRACE")) return Level.TRACE;
+    return defaultLevel;
+  }
+
+    /**
+     * Custom deserialization of Level.
+     * @param s serialization stream.
+     * @throws IOException if IO exception.
+     * @throws ClassNotFoundException if class not found.
+     */
+    private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
+      s.defaultReadObject();
+      level = s.readInt();
+      syslogEquivalent = s.readInt();
+      levelStr = s.readUTF();
+      if (levelStr == null) {
+          levelStr = "";
+      }
+    }
+
+    /**
+     * Serialize level.
+     * @param s serialization stream.
+     * @throws IOException if exception during serialization.
+     */
+    private void writeObject(final ObjectOutputStream s) throws IOException {
+        s.defaultWriteObject();
+        s.writeInt(level);
+        s.writeInt(syslogEquivalent);
+        s.writeUTF(levelStr);
+    }
+
+    /**
+     * Resolved deserialized level to one of the stock instances.
+     * May be overriden in classes derived from Level.
+     * @return resolved object.
+     * @throws ObjectStreamException if exception during resolution.
+     */
+    private Object readResolve() throws ObjectStreamException {
+        //
+        //  if the deserizalized object is exactly an instance of Level
+        //
+        if (getClass() == Level.class) {
+            return toLevel(level);
+        }
+        //
+        //   extension of Level can't substitute stock item
+        //
+        return this;
+    }
+}
\ No newline at end of file

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import java.util.Hashtable;
+
+/**
+ * This class is a factory that creates and maintains org.apache.log4j.Loggers
+ * warpping org.slf4j.Loggers.
+ * 
+ * It keeps a hashtable of all created org.apache.log4j.Logger instances so that
+ * all newly created instances are not dulpicates of existing loggers.
+ * 
+ * @author S&eacute;bastien Pennec
+ */
+class Log4jLoggerFactory {
+
+  private static Hashtable<String, Logger> log4jLoggers = new Hashtable<String, Logger>();
+
+  public static synchronized Logger getLogger(String name) {
+    if (log4jLoggers.containsKey(name)) {
+      return (org.apache.log4j.Logger) log4jLoggers.get(name);
+    } else {
+      Logger log4jLogger = new Logger(name);
+      
+      log4jLoggers.put(name, log4jLogger);
+      return log4jLogger;
+    }
+  }
+
+}

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+public class Logger extends Category {
+
+  Logger(String name) {
+    super(name);
+  }
+
+}

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,28 @@
+package org.apache.log4j;
+
+public class MDC {
+
+  public static void put(String key, String value) {
+    org.slf4j.MDC.put(key, value);
+  }
+  
+  public static void put(String key, Object value) {
+    if (value != null) {
+      put(key, value.toString());
+    } else {
+      put(key, null);
+    }
+  }
+  
+  public static Object get(String key) {
+    return org.slf4j.MDC.get(key);
+  }
+  
+  public static void remove(String key) {
+    org.slf4j.MDC.remove(key);
+  }
+  
+  public static void clear() {
+    org.slf4j.MDC.clear();
+  }
+}

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,192 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+
+// Contributors:  Kitching Simon <Simon.Kitching at orange.ch>
+
+package org.apache.log4j;
+
+/**
+   <font color="#AA4444">Refrain from using this class directly, use
+   the {@link Level} class instead</font>.
+
+   @author Ceki G&uuml;lc&uuml; */
+public class Priority {
+
+  transient int level;
+  transient String levelStr;
+  transient int syslogEquivalent;
+
+  public final static int OFF_INT = Integer.MAX_VALUE;
+  public final static int FATAL_INT = 50000;
+  public final static int ERROR_INT = 40000;
+  public final static int WARN_INT  = 30000;
+  public final static int INFO_INT  = 20000;
+  public final static int DEBUG_INT = 10000;
+    //public final static int FINE_INT = DEBUG_INT;
+  public final static int ALL_INT = Integer.MIN_VALUE;
+
+  /**
+   * @deprecated Use {@link Level#FATAL} instead.
+   */
+  final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
+
+  /**
+   * @deprecated Use {@link Level#ERROR} instead.
+   */
+  final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
+
+  /**
+   * @deprecated Use {@link Level#WARN} instead.
+   */
+  final static public Priority WARN  = new Level(WARN_INT, "WARN",  4);
+
+  /**
+   * @deprecated Use {@link Level#INFO} instead.
+   */
+  final static public Priority INFO  = new Level(INFO_INT, "INFO",  6);
+
+  /**
+   * @deprecated Use {@link Level#DEBUG} instead.
+   */
+  final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
+
+
+  /**
+    * Default constructor for deserialization.
+    */
+  protected Priority() {
+      level = DEBUG_INT;
+      levelStr = "DEBUG";
+      syslogEquivalent = 7;
+  }
+
+  /**
+     Instantiate a level object.
+   */
+  protected
+  Priority(int level, String levelStr, int syslogEquivalent) {
+    this.level = level;
+    this.levelStr = levelStr;
+    this.syslogEquivalent = syslogEquivalent;
+  }
+
+  /**
+     Two priorities are equal if their level fields are equal.
+     @since 1.2
+   */
+  public
+  boolean equals(Object o) {
+    if(o instanceof Priority) {
+      Priority r = (Priority) o;
+      return (this.level == r.level);
+    } else {
+      return false;
+    }
+  }
+
+  /**
+     Return the syslog equivalent of this priority as an integer.
+   */
+  public
+  final
+  int getSyslogEquivalent() {
+    return syslogEquivalent;
+  }
+
+
+   
+  /**
+     Returns <code>true</code> if this level has a higher or equal
+     level than the level passed as argument, <code>false</code>
+     otherwise.  
+     
+     <p>You should think twice before overriding the default
+     implementation of <code>isGreaterOrEqual</code> method.
+
+  */
+  public
+  boolean isGreaterOrEqual(Priority r) {
+    return level >= r.level;
+  }
+
+  /**
+     Return all possible priorities as an array of Level objects in
+     descending order.
+
+     @deprecated This method will be removed with no replacement.
+  */
+  public
+  static
+  Priority[] getAllPossiblePriorities() {
+    return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN, 
+                                                   Priority.INFO, Priority.DEBUG};
+  }
+
+
+  /**
+     Returns the string representation of this priority.
+   */
+  final
+  public
+  String toString() {
+    return levelStr;
+  }
+
+  /**
+     Returns the integer representation of this level.
+   */
+  public
+  final
+  int toInt() {
+    return level;
+  }
+
+  /**
+   * @deprecated Please use the {@link Level#toLevel(String)} method instead.
+  */
+  public
+  static
+  Priority toPriority(String sArg) {
+    return Level.toLevel(sArg);
+  }
+
+  /**
+   * @deprecated Please use the {@link Level#toLevel(int)} method instead.   
+   */
+  public
+  static
+  Priority toPriority(int val) {
+    return toPriority(val, Priority.DEBUG);
+  }
+
+  /**
+   * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.   
+  */
+  public
+  static
+  Priority toPriority(int val, Priority defaultPriority) {
+    return Level.toLevel(val, (Level) defaultPriority);
+  }
+
+  /**
+   * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.   
+   */
+  public
+  static
+  Priority toPriority(String sArg, Priority defaultPriority) {                  
+    return Level.toLevel(sArg, (Level) defaultPriority);
+  }
+}
\ No newline at end of file

Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+
+
+<html> 
+  <head>
+      <title></title>
+  </head>
+  
+
+  <body>
+  
+ <p>An rather minimal but sufficient implementation redirecting all
+ calls to a log4j logger to a logback logger.</p>
+
+  </body> 
+</html>
+
+

Added: slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/DummyObject.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/DummyObject.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,8 @@
+package org.apache.log4j;
+
+public class DummyObject {
+
+  public String toString() {
+    return "dummy";
+  }
+}

Added: slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/LoggerTest.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/LoggerTest.java	Mon Jul  9 22:24:02 2007
@@ -0,0 +1,168 @@
+package org.apache.log4j;
+
+import junit.framework.TestCase;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
+
+/**
+ * A class that tests the invocation of the org.apache.log4j.Logger class that
+ * belongs to the log4j-bridge package
+ * 
+ * @author S&eacute;bastien Pennec
+ * @author Ceki G&uuml;lc&uuml;
+ */
+
+public class LoggerTest extends TestCase {
+
+  LoggerContext context;
+  ListAppender<LoggingEvent> appender;
+  ch.qos.logback.classic.Logger logbackLogger;
+  org.apache.log4j.Logger log4jLogger;
+
+  public void setUp() throws Exception {
+    context = (LoggerContext) LoggerFactory.getILoggerFactory();
+    context.shutdownAndReset();
+    appender = new ListAppender<LoggingEvent>();
+    appender.setContext(context);
+    appender.setName("listAppender");
+    appender.start();
+    ch.qos.logback.classic.Logger lbLogger = context
+        .getLogger(LoggerContext.ROOT_NAME);
+    lbLogger.addAppender(appender);
+
+    log4jLogger = org.apache.log4j.Logger.getLogger(LoggerTest.class);
+    logbackLogger = context.getLogger(LoggerTest.class);
+    super.setUp();
+  }
+
+  public void tearDown() throws Exception {
+    appender.stop();
+    context.stop();
+    appender = null;
+    context = null;
+    logbackLogger = null;
+    log4jLogger = null;
+    super.tearDown();
+  }
+
+  public void testLogWithObjectMessages() {
+    LoggingEvent event;
+
+    log4jLogger.debug("test");
+    event = appender.list.get(0);
+    assertEquals("test", event.getMessage());
+    appender.list.clear();
+
+    log4jLogger.debug(null);
+    event = appender.list.get(0);
+    assertEquals(null, event.getMessage());
+    appender.list.clear();
+
+    DummyObject dummy = new DummyObject();
+    log4jLogger.debug(dummy);
+    event = appender.list.get(0);
+    assertEquals(dummy.toString(), event.getMessage());
+    appender.list.clear();
+  }
+
+  public void testIsEnabledAPI() {
+    assertFalse(log4jLogger.isTraceEnabled());
+    assertTrue(log4jLogger.isDebugEnabled());
+    assertTrue(log4jLogger.isInfoEnabled());
+    assertTrue(log4jLogger.isWarnEnabled());
+    assertTrue(log4jLogger.isErrorEnabled());
+  }
+
+  public void testPrintAPI() {
+    Exception e = new Exception("just testing");
+
+    log4jLogger.trace(null);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+    
+    log4jLogger.debug(null);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.debug("debug message");
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.info(null);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.info("info  message");
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.warn(null);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.warn("warn message");
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.error(null);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.error("error message");
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.debug(null, e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.debug("debug message", e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.info(null, e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.info("info  message", e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.warn(null, e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.warn("warn message", e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.error(null, e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+    log4jLogger.error("error message", e);
+    assertEquals(1, appender.list.size());
+    appender.list.clear();
+
+  }
+  
+  public void testLogAPI() {
+    log4jLogger.log("x", Level.TRACE, "x", null);
+    assertEquals(0, appender.list.size());
+
+    log4jLogger.log("x", Level.DEBUG, "x", null);
+    log4jLogger.log("x", Level.INFO, "x", null);
+    log4jLogger.log("x", Level.WARN, "x", null);
+    log4jLogger.log("x", Level.ERROR, "x", null);
+    log4jLogger.log("x", Level.FATAL, "x", null);
+
+    assertEquals(5, appender.list.size());
+    appender.list.clear();
+
+  }
+
+}

Modified: slf4j/trunk/pom.xml
==============================================================================
--- slf4j/trunk/pom.xml	(original)
+++ slf4j/trunk/pom.xml	Mon Jul  9 22:24:02 2007
@@ -31,6 +31,7 @@
     <module>slf4j-log4j12</module>
     <module>slf4j-jcl</module>
     <module>jcl104-over-slf4j</module>
+    <module>log4j-over-slf4j</module>
     <module>slf4j-site</module>
     <module>slf4j-archetype</module>
 



More information about the slf4j-dev mailing list