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

Logback swallows output from Exceptions overriding toString()

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.2.1
    • logback-classic
    • None
    • Windows, Java 8

    Description

      When logging exceptions that overwrite toString() then logback ignores the output of it. For example:

         class OverridingException extends Exception {
              @Override
              public String toString() {
                  return super.toString() + " important additional information";
              }
          }

      When used with logback the following code  

       @Test
          public void testName() {
              org.slf4j.Logger logger = LoggerFactory.getLogger(LoggerTest.class);
              try {
                  throw new OverridingException();
              } catch (Throwable t) {
                  logger.error("", t);
              }
          }

      produces output without the string "important additional information"

      2017-03-08 16:44:27 [main] ERROR trial.LoggerTest - 
      trial.LoggerTest$OverridingException: null
          at trial.LoggerTest.testName(LoggerTest.java:32)

      while Java Util Logging outputs correctly

      Mär 08, 2017 4:44:27 PM trial.LoggerTest testLogging
      SCHWERWIEGEND: 
      trial.LoggerTest$OverridingException important additional information
          at trial.LoggerTest.testLogging(LoggerTest.java:22)

      Testfile and logback.xml attached.

       

       

       

       

      Attachments

        Activity

          People

            logback-dev Logback dev list
            Graf Claus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: