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?

有帮助吗?

解决方案

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.

其他提示

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()

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top