You can use the ExceptionUtils.getStackTrace(Throwable t);
from Apache Commons 3 class org.apache.commons.lang3.exception.ExceptionUtils
.
http://commons.apache.org/proper/commons-lang/
ExceptionUtils.getStackTrace(Throwable t)
Code example:
try {
// your code here
} catch(Exception e) {
String s = ExceptionUtils.getStackTrace(e);
}