scala 将异常信息完成输出到日志中

scala 将异常信息完成输出到日志中


/**
* scala 将异常信息完成输出到日志中
* @param e
* @param data
*/
def printStackTraceStr(e: Exception, data: String) = {
val sw:StringWriter = new StringWriter()
val pw:PrintWriter = new PrintWriter(sw)
e.printStackTrace(pw)
println("======>>printStackTraceStr Exception: " + e.getClass() + "\n==>" + sw.toString () + "\n==>data=" + data)
}

你可能感兴趣的:(Scala)