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

SLF4J extensions relying on the LoggerWrapper class fail to log the exception on a parameterized query

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • None
    • None

    Description

      When a logging statement occurs using an extending class, in my case, XLogger, with a parameterized query, on a LocationAwareLogger, the LoggerWrapper will use the MessageFormatter, format the message, and then pass it onto the bounded logger with null as the throwable. The MessageFormatter has already identified the exception, if applicable, and parsed it out of the object list. It has also generated an object list for the remaining objects. In my case, the underlying logged, log4j12, simply ignored the object list, used the formatted string, and saw null for the exception.
      Attached is a very simple example (with pom and log4j.properties file) to demonstrate the problem.

      LoggerWrapperFailureDemo.java
      package demo.slf4j.ext;
      
      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;
      import org.slf4j.ext.XLogger;
      
      public class LoggerWrapperFailureDemo
      {
      	static XLogger logger = new XLogger(LoggerFactory.getLogger(LoggerWrapperFailureDemo.class));
      	static Logger traditional = LoggerFactory.getLogger(LoggerWrapperFailureDemo.class);
      	
          public static void main( String[] args )
          {
          	Exception e = new Exception("foo", new Exception("bar"));
              logger.warn( "No Param", e);
              logger.warn( "Param: {}", "etc", e);
              traditional.warn( "No XLogger (So No LoggerWrapper {} ", "etc", e);
          }
      }
      

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            wm William Miller
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: