Another little and easy tip I often use. The task is to redirect the Throwable.printStackTrace() over a String object. In this way you can manage the string including it, for example, in an XML stream.
Less words, here it is
// "t" is an instance of Throwable //... StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); String error = sw.toString(); pw.close(); sw.close(); //...