开发者

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 sta开发者_运维知识库ck. Can I somehow see callstack as well? It would let me better understand what is the problem.


printStackTrace() or getStackTrace()?


You can call an Exception object's printStackTrace() method.

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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜