terça-feira, 30 de dezembro de 2008

java: log Stack Trace of exception

We can log the stacktrace of a exception by using the following function to build the String:

// function to compose the stacktrace of a exception to a String
public static String getStackTrace(Throwable aThrowable) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
aThrowable.printStackTrace(printWriter);
return result.toString();
}

Sem comentários:

Enviar um comentário