问题
When I run some java program with a command java ExceptionTest , exceptions are sometimes omitted and looks like
Exception in thread "main" java.lang.NoClassDefFoundError: aa/bb/DD
at SOMEWHERE(unknown source)
Caused by: java.lang.ClassNotFoundException: aaa.bbb.CC
at SOMEWHER(unknown source)
... 13 more
I'd like to see 13 more exceptions in this case. Is there an option to see all exception log?
回答1:
You already see them, it's only the ridiculous way Java (and Logback by defaul) prints exceptions by default. This stack trace:
Exception in thread "main" java.lang.NoClassDefFoundError: aa/bb/DD
at SOMEWHERE(unknown source)
Caused by: java.lang.ClassNotFoundException: aaa.bbb.CC
at SOMEWHER(unknown source)
... 13 more
actually means the following program flow (from bottom to top):
Caused by: java.lang.ClassNotFoundException: aaa.bbb.CC
at SOMEWHER(unknown source)
Exception in thread "main" java.lang.NoClassDefFoundError: aa/bb/DD
at SOMEWHERE(unknown source)
The ... 13 more
(N common frames omitted
in Logback) only means that these exceptions were already printed before. In Logback you can restructure stack track to avoid duplicates and print stack lines always in correct order, see my blog.
回答2:
there aren't 13 more exceptions. There are 13 more lines to the call stack which are identical to previous call stacks, as described here: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Throwable.html#printStackTrace()
来源:https://stackoverflow.com/questions/12226375/how-can-i-see-a-full-log-of-exceptions-in-java