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

Logback doesn't use Throwable.printStackTrace(), thus not allowing exceptions to inject their own information into stacktrace

    XMLWordPrintable

Details

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

    Description

      As can be seen from file ThrowableProxyConverter, Logback doesn't call exception's printStackTrace() method, but uses some custom stacktrace dumping procedure. This appears just fine for standard exceptions, but the problem is, this method is not final and can be overriden. As a result, for certain exceptions results of "standard" stacktrace dumping and Logback output differ.

      Usecase important for me is Jython exceptions. They splice Python stacktrace into Java stacktrace by overriding printStackTrace().

      For comparison, here are parts of the same exception stacktrace. How it appears with exception.printStackTrace (...):

      ...
      at java.lang.Thread.run(Thread.java:745)
      Caused by: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "test.py", line 3, in main
      ValueError: this is a test error

      at org.python.core.PyException.doRaise(PyException.java:219)
      at org.python.core.Py.makeException(Py.java:1166)
      ...

      How it appears in log file:

      at java.lang.Thread.run(Thread.java:745)
      Caused by: org.python.core.PyException: null
      at org.python.core.PyException.doRaise(PyException.java:219)
      at org.python.core.Py.makeException(Py.java:1166)
      ...

      Logback probably does it for performance reasons, but in this case, for me at least, full stacktrace is infinitely more important than performance, because exceptions don't happen often anyway.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            doublep Paul Pogonyshev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: