@Test
public void jsonLayout() throws Exception {

    configure("src/test/input/json/jsonLayout.xml");
    String loggerName = "ROOT";
    String message = "Info message";
    String debugMessage = "Debug message";
    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    logger.info("Test");
    ILoggingEvent event = new LoggingEvent("my.class.name", logger, Level.INFO, message, null, null);
    JsonLayout jsonLayout = new JsonLayout();
    jsonLayout.setContext(context);
    String log = jsonLayout.doLayout(event);
    assertTimestamp(log);
    assertThat(log, containsString(String.format("%s=%s", JsonLayout.LEVEL_ATTR_NAME, Level.INFO)));
    assertThat(log, containsString(String.format("%s=%s", JsonLayout.THREAD_ATTR_NAME, "main")));
    assertThat(log, containsString(String.format("%s=%s", JsonLayout.LOGGER_ATTR_NAME, loggerName)));
    assertThat(log, containsString(String.format("%s=%s", JsonLayout.FORMATTED_MESSAGE_ATTR_NAME, message)));
    jsonLayout.setIncludeContextName(true);
    jsonLayout.setIncludeMDC(true);
    jsonLayout.setIncludeLoggerName(true);
    jsonLayout.setIncludeException(true);
    jsonLayout.setIncludeMessage(true);
    RuntimeException exception = new RuntimeException("Exception");
    ILoggingEvent eventWithException = new LoggingEvent("my.class.name", logger, Level.DEBUG, debugMessage, exception, null);
    String logWithException = jsonLayout.doLayout(eventWithException);
    assertTimestamp(logWithException);
    assertThat(logWithException, containsString(String.format("%s=%s", JsonLayout.LEVEL_ATTR_NAME, Level.DEBUG)));
    assertThat(logWithException, containsString(String.format("%s=%s", JsonLayout.LOGGER_ATTR_NAME, loggerName)));
    assertThat(logWithException, containsString(String.format("%s=%s", JsonLayout.FORMATTED_MESSAGE_ATTR_NAME, debugMessage)));
    assertThat(logWithException, containsString(String.format("%s=%s", JsonLayout.MESSAGE_ATTR_NAME, debugMessage)));
    assertThat(logWithException, containsString(String.format("%s=%s", JsonLayout.EXCEPTION_ATTR_NAME, exception.toString())));
}