在日常处理中,一般对异常的处理是e.printstrace,但如要记录到 string的话,
一般是这个做法:
但如果用apache common包,则可以有这个exceptionutils,
String str = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(Throwable);
一般是这个做法:
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
errorMsg = sw.toString();
但如果用apache common包,则可以有这个exceptionutils,
String str = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(Throwable);