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.
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