java在日志中打印异常堆栈信息

public static String logExceptionStack(Exception e){
  StringWriter stringWriter=new StringWriter();
e.printStackTrace(new PrintWriter(StringWriter));
return stringWriter.toString();
}