字符串输出异常信息
作者:互联网
private String getStackTraceAsString() { // StringWriter将包含堆栈信息 StringWriter stringWriter = new StringWriter(); //必须将StringWriter封装成PrintWriter对象, //以满足printStackTrace的要求 PrintWriter printWriter = new PrintWriter(stringWriter); //获取堆栈信息 e.printStackTrace(printWriter); //转换成String,并返回该String StringBuffer error = stringWriter.getBuffer(); return error.toString(); }
可用于配置全局切面
标签:输出,PrintWriter,String,StringWriter,printStackTrace,stringWriter,字符串,new,异常 来源: https://www.cnblogs.com/DarkerbeS/p/15234754.html