哪位帮忙详细解释一下异常处理时,写日志使用
java api Exception中的getStackTrace()方法和org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)
两者有什么区别,对程序有什么影响?
java api Exception中的getStackTrace()方法和org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)
两者有什么区别,对程序有什么影响?
org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e):public static String getStackTrace(Throwable throwable) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
throwable.printStackTrace(pw);
return sw.getBuffer().toString();
}
getStackTrace():public class Exception extends Throwable
Throwable的代码就不贴了,你自己看下呗。