@Test
  public void testException() throws Exception {

    Logger logger = Logger.getLogger(getClass());

    logger.info(LOG_MESSAGE, new Exception("this is an exception"));
    assertEquals(1, GelfTestSender.getMessages().size());

    GelfMessage gelfMessage = GelfTestSender.getMessages().get(0);

    assertEquals(LOG_MESSAGE, gelfMessage.getFullMessage());
    assertEquals(
        AbstractGelfLogAppenderTest.class.getName(),
        gelfMessage.getField(LogMessageField.NamedLogField.SourceClassName.getFieldName()));
    assertEquals(
        "testException",
        gelfMessage.getField(LogMessageField.NamedLogField.SourceMethodName.getFieldName()));

    assertThat(
        gelfMessage.getField(MdcGelfMessageAssembler.FIELD_STACK_TRACE),
        containsString("this is an exception"));
    assertThat(
        gelfMessage.getField(MdcGelfMessageAssembler.FIELD_STACK_TRACE), containsString("skipped"));
    assertThat(
        gelfMessage.getField(MdcGelfMessageAssembler.FIELD_STACK_TRACE), containsString("skipped"));
  }
  @Test
  public void testFields() throws Exception {

    Logger logger = Logger.getLogger(getClass());
    MDC.put("mdcField1", "a value");
    MDC.remove(GelfUtil.MDC_REQUEST_START_MS);

    logger.info(LOG_MESSAGE);
    assertEquals(1, GelfTestSender.getMessages().size());

    GelfMessage gelfMessage = GelfTestSender.getMessages().get(0);

    assertEquals("fieldValue1", gelfMessage.getField("fieldName1"));
    assertEquals("fieldValue2", gelfMessage.getField("fieldName2"));
    assertEquals("a value", gelfMessage.getField("mdcField1"));
    assertNotNull(gelfMessage.getField(LogMessageField.NamedLogField.SourceLineNumber.name()));
    assertEquals(
        "testFields", gelfMessage.getField(LogMessageField.NamedLogField.SourceMethodName.name()));
    assertEquals(
        AbstractGelfLogAppenderTest.class.getName(),
        gelfMessage.getField(LogMessageField.NamedLogField.SourceClassName.name()));
    assertEquals("a value", gelfMessage.getField("mdcField1"));
    assertNull(gelfMessage.getField("mdcField2"));

    assertNull(gelfMessage.getField(GelfUtil.MDC_REQUEST_DURATION));
    assertNull(gelfMessage.getField(GelfUtil.MDC_REQUEST_END));
  }