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

ThrowableProxyUtil.printFirstLine - allow customisation of output (use Throwable.toString instead of getMessage)

    XMLWordPrintable

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • 1.5.7
    • 0.9.28
    • logback-classic
    • None

    Description

      I have a custom exception class (BaseException) with an "errorCode" attribute, and overridden the toString method to return errorCode + Exception.getMessage

      log4j is simply using toString(), which logs the exceptions as required.

      ThrowableProxyUtil.printFirstLine uses
      buf.append(tp.getClassName()).append(": ").append(tp.getMessage());

      In some cases, Exception.getMessage will return null, as my application will only return the error code to the caller.

      Can logback provide an option to use toString instead of manually appending the class name and getMessage? or simply use toString?

      Attachments

        Activity

          People

            logback-dev Logback dev list
            alvincys Alvin Chee
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: