[英]Configure Java installation to print only the first few lines of stack trace
How can I configure the default java stack trace printing behaviour so only the head is visible? 如何配置默认的Java堆栈跟踪打印行为,以便只显示头部? Currently I use
2>&1 | head
目前我使用
2>&1 | head
2>&1 | head
or | less -i
2>&1 | head
或| less -i
| less -i
and I find it suboptimal. | less -i
,我发现它不是最理想的。
When having an uncaught exception, Java prints me 115 lines and then the text ... 102 more
. 当有一个未被捕获的异常时,Java会打印115行,然后是文本
... 102 more
。 99% to 97% of this trace is irrelevant to me. 99%到97%的这种痕迹与我无关。 This leaves the first 3 lines interesting.
这使前3行变得有趣。
How can I configure Java to print me 2 lines and then, in my example case, ... 215 more
? 如何配置Java以打印2行,然后,在我的示例中,
... 215 more
?
You can specify JVM parameter MaxJavaStackTraceDepth
: 您可以指定JVM参数
MaxJavaStackTraceDepth
:
-XX:MaxJavaStackTraceDepth=2
You can set this parameter in your run script. 您可以在运行脚本中设置此参数。 If you use IDE, there's a VM options or VM arguments field in a run configuration dialog.
如果使用IDE,则运行配置对话框中有VM选项或VM参数字段。 You can set the above parameter in the field.
您可以在字段中设置以上参数。
For more detail, please refer to http://stas-blogspot.blogspot.kr/2011/07/most-complete-list-of-xx-options-for.html#MaxJavaStackTraceDepth 有关更多详细信息,请参阅http://stas-blogspot.blogspot.kr/2011/07/most-complete-list-of-xx-options-for.html#MaxJavaStackTraceDepth
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.