如何增加Java堆栈跟踪转储的显示行数? [英] How do I increase the number of displayed lines of a Java stack trace dump?

查看:236
本文介绍了如何增加Java堆栈跟踪转储的显示行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法制作 Throwable.printStackTrace(PrintStream s) 打印完整的堆栈跟踪,以便我可以看到<$ c $的最后一行c>...... 40多个?

推荐答案

你不需要;该信息存在于堆栈跟踪的其他位置。来自 printStackTrace()

You don't need to; that information is present elsewhere in the stack trace. From the docs of printStackTrace():


注意是否存在包含字符<$ c $的行C> ...。这些行表示此异常的堆栈跟踪的其余部分匹配由此异常(封闭异常)引起的异常的堆栈跟踪底部的指定帧数。

Note the presence of lines containing the characters "...". These lines indicate that the remainder of the stack trace for this exception matches the indicated number of frames from the bottom of the stack trace of the exception that was caused by this exception (the "enclosing" exception).

这种简写可以大大减少输出的长度,在常见情况下,从捕获致使异常的同一方法抛出包装异常。

This shorthand can greatly reduce the length of the output in the common case where a wrapped exception is thrown from same method as the "causative exception" is caught.

换句话说,... x more仅出现在链式异常中,并且仅在最后一次出现时 x 堆栈跟踪的行已作为另一个链式异常的堆栈跟踪的一部分出现。

In other words, the "... x more" only appears on a chained exception, and only when the last x lines of the stack trace are already present as part of another chained exception's stack trace.

假设一个方法捕获异常Foo,将其包装在异常Bar中,并抛出Bar。然后Foo的堆栈跟踪将缩短。如果由于某种原因需要完整跟踪,那么您需要做的就是在Foo的堆栈跟踪中的 ... 之前的最后一行,并在Bar的堆栈中查找它跟踪;该行下面的所有内容都与Foo的堆栈跟踪中的内容完全相同。

Suppose that a method catches exception Foo, wraps it in exception Bar, and throws Bar. Then Foo's stack trace will be shortened. If you for some reason want the full trace, all you need to do is take the last line before the ... in Foo's stack trace and look for it in the Bar's stack trace; everything below that line is exactly what would have been printed in Foo's stack trace.

这篇关于如何增加Java堆栈跟踪转储的显示行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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