开发者

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

开发者 https://www.devze.com 2023-04-02 03:21 出处:网络
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

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

精彩评论

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

关注公众号