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);
}
精彩评论