本文整理匯總了Java中org.apache.log4j.MDC.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java MDC.clear方法的具體用法?Java MDC.clear怎麽用?Java MDC.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.log4j.MDC
的用法示例。
在下文中一共展示了MDC.clear方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testMDC
import org.apache.log4j.MDC; //導入方法依賴的package包/類
@Test
public void testMDC() throws Exception
{
initialize("TestJsonLayout/default.properties");
MDC.put("foo", "bar");
MDC.put("argle", "bargle");
logger.debug(TEST_MESSAGE);
MDC.clear();
captureLoggingOutput();
assertCommonElements(TEST_MESSAGE);
DomAsserts.assertCount("children of mdc", 2, dom, "/data/mdc/*");
DomAsserts.assertEquals("mdc child 1", "bar", dom, "/data/mdc/foo");
DomAsserts.assertEquals("mdc child 2", "bargle", dom, "/data/mdc/argle");
}
示例2: downloadFeed
import org.apache.log4j.MDC; //導入方法依賴的package包/類
private void downloadFeed(String feedName) {
try {
MDC.put("feed", feedName);
TaxiiStatus.Feed feed = taxiiStatusDao.find(feedName);
if (feed == null) {
feed = new TaxiiStatus.Feed();
feed.setName(feedName);
}
boolean more;
do {
more = pollAndUpdateFeed(feed);
taxiiStatusDao.updateOrAdd(feed);
} while (more);
} catch(Exception e) {
statistics.incrementErrors();
LOG.error("Error while processing feed " + feedName, e);
return ;
} finally {
MDC.clear();
}
}
示例3: clearLog4JThreadLocals
import org.apache.log4j.MDC; //導入方法依賴的package包/類
/**
* Clear Log4J threadlocals
*/
protected static void clearLog4JThreadLocals() {
NDC.remove();
MDC.clear();
ThreadLocal tl = getMDCThreadLocal();
if (tl != null) {
tl.remove();
}
}
示例4: after
import org.apache.log4j.MDC; //導入方法依賴的package包/類
@After
public void after() {
MDC.clear();
}