本文整理汇总了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();
}