@Override public final void run() { NDC.inherit(ndcStack); try { runInternal(); } finally { NDC.clear(); } }
@Test public void testSimpleInfo() throws Exception { Logger logger = Logger.getLogger(getClass()); NDC.clear(); NDC.push("ndc message"); logger.info(LOG_MESSAGE); NDC.clear(); assertEquals(1, GelfTestSender.getMessages().size()); GelfMessage gelfMessage = GelfTestSender.getMessages().get(0); assertEquals(EXPECTED_LOG_MESSAGE, gelfMessage.getFullMessage()); assertEquals(EXPECTED_LOG_MESSAGE, gelfMessage.getShortMessage()); assertEquals("ndc message", gelfMessage.getField("NDC")); assertNotNull(gelfMessage.getField("MyTime")); assertEquals("6", gelfMessage.getLevel()); assertEquals(8192, gelfMessage.getMaximumMessageSize()); assertEquals(GelfMessage.GELF_VERSION_1_1, gelfMessage.getVersion()); // this is because of default-logstash-fields.properties assertEquals("INFO", gelfMessage.getAdditonalFields().get("MySeverity")); }