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.
Not beautiful, but a solution nonetheless:
StringWriter writer = new StringWriter(); PrintWriter printWriter = new PrintWriter( writer ); exception.printStackTrace( printWriter ); printWriter.flush(); String stackTrace = writer.toString();