Print the stack trace of an exception

后端 未结 9 1234
有刺的猬
有刺的猬 2020-12-05 03:31

How do I print the stack trace of an exception to a stream other than stderr? One way I found is to use getStackTrace() and print the entire list to the stream.

9条回答
  •  借酒劲吻你
    2020-12-05 04:13

    Apache commons provides utility to convert the stack trace from throwable to string.

    Usage:

    ExceptionUtils.getStackTrace(e)
    

    For complete documentation refer to https://commons.apache.org/proper/commons-lang/javadocs/api-release/index.html

提交回复
热议问题