如何在JAVA中查看完整的异常日志? [英] How can I see a full log of exceptions in JAVA?

查看:1576
本文介绍了如何在JAVA中查看完整的异常日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用命令 java ExceptionTest 运行某些java程序时,有时会省略异常,看起来像

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

我想要在这种情况下看到13个例外。有没有选项可以查看所有异常日志?

I'd like to see 13 more exceptions in this case. Is there an option to see all exception log?

推荐答案

你已经看到了它们,默认情况下,Java(和defaul的Logback)打印异常只是荒谬的。此堆栈跟踪:

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)

。 .. 13 more 在Logback中省略N个常见帧)仅表示之前已经打印过这些例外。在Logback中,您可以重新构建堆栈跟踪以避免重复并始终以正确的顺序打印堆栈行,请参阅我的博客

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.

这篇关于如何在JAVA中查看完整的异常日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆