简体   繁体   English

除了Java应用程序中的异常名称和描述外,还输出调用堆栈

[英]Outputing call stack in addition to exception name and description in java application

I executing a java application and I see some exception but not call stack. 我执行一个Java应用程序,但看到一些异常,但没有调用堆栈。 Can I somehow see callstack as well? 我还能以某种方式看到调用栈吗? It would let me better understand what is the problem. 这会让我更好地了解问题所在。

printStackTrace()getStackTrace()吗?

You can call an Exception object's printStackTrace() method. 您可以调用Exception对象的printStackTrace()方法。

More information here . 更多信息在这里

try{
//code
}catch(Exception ex){
ex.printStackTrace();
}

You might consider using a logger instead 您可以考虑改用记录器

try{
//code
}catch(Exception ex){
LOG.warn("whatever went wrong", ex);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM