Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-122

log4j-over-slf4j not reporting correct source class and method

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.5.x
    • Fix Version/s: None
    • Component/s: log4j-over-slf4j
    • Labels:
      None
    • Environment:

      Operating System: Mac OS X 10.3
      Platform: Macintosh

      Description

      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@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 ${*}

        Attachments

          Activity

            People

            • Assignee:
              slf4j-dev SLF4J developers list
              Reporter:
              zampettim@aim.com Marc Zampetti
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: