@Test public void testProvider() throws IOException { LoggerContext context = new LoggerContext(); context.getStatusManager().add(new OnConsoleStatusListener()); createExceptionMappingRegistry(context); StringWriter writer = new StringWriter(); JsonGenerator g = mkJsonGenerator(writer); ExceptionArgumentsProvider provider = new ExceptionArgumentsProvider(); provider.setContext(context); provider.setFieldName("exception"); provider.start(); ILoggingEvent event = mkLoggingEvent(context); g.writeStartObject(); provider.writeTo(g, event); g.writeEndObject(); g.flush(); g.close(); String s = writer.toString(); assertThat(s) .isEqualTo( "{\"exception\":[{\"name\":\"java.lang.RuntimeException\",\"properties\":{\"message\":\"derp\"}}]}"); }
@Override public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException { writeExceptionIfNecessary(generator, event.getThrowableProxy()); }
ExceptionArgumentsProvider extends AbstractFieldJsonProvider<ILoggingEvent> { @Override public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException { writeExceptionIfNecessary(generator, event.getThrowableProxy()); } }
ExceptionArgumentsProvider extends AbstractFieldJsonProvider<ILoggingEvent> { @Override public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException { writeExceptionIfNecessary(generator, event.getThrowableProxy()); }  }
ExceptionArgumentsProvider extends AbstractFieldJsonProvider<ILoggingEvent> { @Override public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException { writeExceptionIfNecessary(generator, event.getThrowableProxy()); }  @Override void writeTo(JsonGenerator generator, ILoggingEvent event); }
ExceptionArgumentsProvider extends AbstractFieldJsonProvider<ILoggingEvent> { @Override public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException { writeExceptionIfNecessary(generator, event.getThrowableProxy()); }  @Override void writeTo(JsonGenerator generator, ILoggingEvent event);  }