LogbackUtil { public static void addException(IThrowableProxy throwableProxy, String message, LogDataBuilder builder) { if (throwableProxy != null) { StringBuilder sb = new StringBuilder(); sb.append(message).append("\n"); sb.append(throwableProxy.getClassName()).append(": ").append(throwableProxy.getMessage()).append("\n"); for (StackTraceElementProxy stackTraceElementProxy : throwableProxy.getStackTraceElementProxyArray()) { sb.append("\t").append(stackTraceElementProxy.getSTEAsString()).append("\n"); } builder.withMessage(sb.toString()); } }  static LogDataBuilder translate(ILoggingEvent ev); static void addCallerData(ILoggingEvent ev, LogDataBuilder builder); static void addException(IThrowableProxy throwableProxy, String message, LogDataBuilder builder); static void addMarker(Marker marker, Map<String, String> mdcMap, LogDataBuilder builder); static Level convertLevel(ch.qos.logback.classic.Level level);  }
@Test public void testAddException() throws Exception { final Exception throwable = new Exception("Some exception"); final StringWriter stringWriter = new StringWriter(); throwable.printStackTrace(new PrintWriter(stringWriter)); ThrowableProxy throwableProxy = new ThrowableProxy(throwable); LogbackUtil.addException(throwableProxy,"Message!", builder); final LogData logData = builder.build(); assertEquals(logData.getMessage(), "Message!\n" + stringWriter.getBuffer().toString()); }