Exception information is output to the 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();
    }

}

Guess you like

Origin blog.csdn.net/yz18931904/article/details/131216647