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

thrown from toString exception swallowed

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 0.9.15
    • None
    • None
    • java version "1.6.0_12"
      Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
      Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
      slf4j-api:1.5.6

    Description

      package loggerbug;

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

      public class Loggerbug
      {
      private static final Logger logger = LoggerFactory.getLogger(Loggerbug.class);

      static class ThrowsToString {
      @Override
      public String toString()

      { throw new RuntimeException("from toString"); }

      }

      public static void main(String[] args)
      {
      ThrowsToString probe = new ThrowsToString();
      logger.info("probe is {}", probe);
      System.out.println("no exception");
      }
      }

      prints "no exception" with logback-classic, but with slf4j-simple output is:

      Exception in thread "main" java.lang.RuntimeException: from toString
      at loggerbug.Loggerbug$ThrowsToString.toString(Loggerbug.java:13)
      at java.lang.String.valueOf(String.java:2827)
      at java.lang.StringBuffer.append(StringBuffer.java:219)
      at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:237)
      at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:196)
      at org.slf4j.helpers.MessageFormatter.format(MessageFormatter.java:138)
      at org.slf4j.impl.SimpleLogger.formatAndLog(SimpleLogger.java:222)
      at org.slf4j.impl.SimpleLogger.info(SimpleLogger.java:258)
      at loggerbug.Loggerbug.main(Loggerbug.java:20)

      Attachments

        Activity

          People

            logback-dev Logback dev list
            mabrek Anton Lebedevich
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: