在Java中可选择打印堆栈跟踪

在Java中可选择打印堆栈跟踪

本文介绍了在Java中可选择打印堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个可以抛出异常的Java应用程序。我在try-catch块中处理这些异常并打印适当的消息,以便业务用户在发生故障时不必看到丑陋的堆栈跟踪。



但是现在调试时,我想调用JAR文件,以便它为我打印堆栈的踪迹,以便我可以知道问题在哪里。



有人可以启发我如何才能实现?

解决方案

为什么不使用记录级别?您的技术错误
INFO ERROR 与业务相关的p>

DEBUG 您的用户了解的代码。


I am creating a java application in which there is a possibility that exceptions might be thrown. I am handling these exceptions in a try-catch block and printing appropriate messages so that the business users don't have to see the ugly stack trace in case of a failure.

But now when I debug, I would like to invoke the JAR file in such a way that it will print the stack traces for me, so that I can know where exactly the problem lies.

Can someone enlighten me on how this can be achieved?

解决方案

Why not use Logging levels.?

DEBUG for your technical errorsand INFO or ERROR with the business codes that your users understand.

这篇关于在Java中可选择打印堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 08:50