异常信息输出到log日志里面

package com.bjshenpu.spcloud.dajia.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

public class ExcrptionUtils {
/* Converts a Throwable object's stack trace to a string.
 * @param t the Throwable object to convert
 * @return a string representation of the stack trace
 */
    public static String printStackTraceToString(Throwable t) {
        StringWriter sw = new StringWriter();
        try (PrintWriter pw = new PrintWriter(sw, true)) {
            t.printStackTrace(pw);
        }
        return sw.toString();
    }

}

你可能感兴趣的:(java,android,开发语言)