Here you can find the source of formatException(Throwable e)
Necessary because slf4j does not by default have a method for logging exceptions
Parameter | Description |
---|---|
e | Exception |
public static String formatException(Throwable e)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { /**// w w w .ja v a 2 s . co m * Formats an exception as a string for logging purposes * <p> * Necessary because slf4j does not by default have a method for logging * exceptions * </p> * * @param e * Exception * @return String for logging purposes */ public static String formatException(Throwable e) { StringWriter writer = new StringWriter(); PrintWriter pwriter = new PrintWriter(writer); writer.append(e.getClass().getCanonicalName()); if (e.getMessage() != null) { writer.append(": "); writer.append(e.getMessage()); } writer.append('\n'); e.printStackTrace(pwriter); pwriter.flush(); return writer.toString(); } }