获取Exception错误的详细信息(堆栈信息)

/**
	 * 获取错误的堆栈信息
	 * @param throwable
	 * @return
	 */
	public String getStackTrace(Throwable throwable){
		StringWriter stringWriter=new StringWriter();
		PrintWriter printWriter=new PrintWriter(stringWriter);

		try {
			throwable.printStackTrace(printWriter);
			return stringWriter.toString();
		}finally {
			printWriter.close();
		}

	}

你可能感兴趣的:(Java)