Logging a stacktrace
try {
Something that throws an Exception
} catch (final XxxException e) {
LOG.error("Some message", e);
}
or
try {
Something that throws an Exception
} catch (final XxxException e) {
final StringWriter w = new StringWriter(10000);
final PrintWriter pw = new PrintWriter(w);
e.printStackTrace(pw);
// Do something with 'w' which now
// contains the formatted stacktrace
}
Comments