2012-09-01 63 views
7

當我運行一個命令的Java ExceptionTest一些java程序,例外有時省略,看起來像如何在JAVA中查看完整的日誌記錄?

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 

我想看看在這種情況下,13個例外。有沒有選擇查看所有異常日誌?

+0

嘗試使用log4j。 –

回答

13

你已經看到它們了,它只是Java(和默認的Logback)默認打印異常的荒謬方式。該堆棧跟蹤:

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 

實際上意味着下面的程序流(從底部到頂部):

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) 

... 13 moreN common frames omitted在的logback)僅意味着在這些異常已經之前打印。在Logback中,您可以重新構建堆棧軌道以避免重複並按正確順序打印堆棧行,請參見my blog

相關問題