Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1083

Exceptions are logged with stack trace despite the existence of a place holder in the pattern

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.1.3
    • logback-classic
    • None

    Description

      This issue reports on a regression introduced in 1.1.*. In 1.0.13 the following test program:

      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;

      public class Test
      {
      private static final Logger LOGGER = LoggerFactory.getLogger(Test.class);

      public static void main(String[] args)
      {
      LOGGER.warn("foo {} {}", "bla", new Exception("bar"));
      }
      }

      logs

      11:45:29.278 [main] WARN Test - foo bla java.lang.Exception: bar

      In 1.1.1 the same program logs:

      11:46:03.664 [main] WARN Test - foo bla {}
      java.lang.Exception: bar
      at Test.main(Test.java:14) [tmp/:na]

      Thus in 1.1.1 logback unconditionally removes the exception from the argument array and logs the stack trace despite there being a placeholder for it in the pattern.

      Since SLF4J has a special method for the case of logging an exception (Logger#warn(String,Throwable)), I would expect the the behavior observed with 1.0.* to be the correct one.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            behrmann Gerd Behrmann
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: