[slf4j-dev] [Bug 131] New: log4j-over-slf4j not reporting correct source class and method

bugzilla-daemon at pixie.qos.ch bugzilla-daemon at pixie.qos.ch
Thu Mar 26 22:34:40 CET 2009


http://bugzilla.slf4j.org/show_bug.cgi?id=131

           Summary: log4j-over-slf4j not reporting correct source class and
                    method
           Product: SLF4J
           Version: 1.5.x
          Platform: Macintosh
        OS/Version: Mac OS X 10.3
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: log4j-over-slf4j
        AssignedTo: dev at slf4j.org
        ReportedBy: zampettim at aim.com


Using log4j-over-slf4j and jdk logging reports the wrong Source Class Name and
Source Class Method in the final log output.

Example code to exercise this:

package bug.test;

public class LoggingTestBean
{
  public static final org.slf4j.Logger slf4jLogger =
org.slf4j.LoggerFactory.getLogger("slf4jLogger");
  public static final java.util.logging.Logger julLogger =
java.util.logging.Logger.getLogger("julLogger");
  public static final org.apache.commons.logging.Log commonsLogger =
org.apache.commons.logging.LogFactory.getLog("commonsLogger");
  public static final org.apache.log4j.Logger l4jLogger =
org.apache.log4j.Logger.getLogger("l4jLogger");


  public void slf4jLogMessage(String message)
  {
    slf4jLogger.info(message);
  }

  public void julLogMessage(String message)
  {
    julLogger.info(message);
  }

  public void commonsLogMessage(String message)
  {
    commonsLogger.info(message);
  }

  public void l4jLogMessage(String message)
  {
    l4jLogger.info(message);
  }


  public static final void main(String[] args)
  {
    try
    {
      LoggingTestBean bean = new LoggingTestBean();

      bean.slf4jLogMessage(args[0]);
      bean.julLogMessage(args[0]);
      bean.commonsLogMessage(args[0]);
      bean.l4jLogMessage(args[0]);
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
  }
}


The output from running this is:

(zampetti at C0A805BC)->./test.sh hello
Mar 26, 2009 5:33:27 PM bug.test.LoggingTestBean slf4jLogMessage
INFO: hello
Mar 26, 2009 5:33:28 PM bug.test.LoggingTestBean julLogMessage
INFO: hello
Mar 26, 2009 5:33:28 PM bug.test.LoggingTestBean commonsLogMessage
INFO: hello
Mar 26, 2009 5:33:28 PM org.apache.log4j.Category info
INFO: hello


And test.sh is:

#!/bin/sh

CP="./target/classes"
CP="${CP}:${HOME}/java/slf4j-1.5.6/slf4j-api-1.5.6.jar"
CP="${CP}:${HOME}/java/slf4j-1.5.6/slf4j-jdk14-1.5.6.jar"
CP="${CP}:${HOME}/java/slf4j-1.5.6/jcl-over-slf4j-1.5.6.jar"
CP="${CP}:${HOME}/java/slf4j-1.5.6/log4j-over-slf4j-1.5.6.jar"

exec java -cp "${CP}" bug.test.LoggingTestBean ${*}


-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the slf4j-dev mailing list