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.
For the android dev minimalists: Log.getStackTraceString(exception)
See javadoc
out = some stream ...
try
{
}
catch ( Exception cause )
{
cause . printStrackTrace ( new PrintStream ( out ) ) ;
}
The Throwable class provides two methods named printStackTrace
, one that accepts a PrintWriter
and one that takes in a PrintStream
, that outputs the stack trace to the given stream. Consider using one of these.