本文整理了Java中org.slf4j.MDC.clear()
方法的一些代码示例,展示了MDC.clear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MDC.clear()
方法的具体详情如下:
包路径:org.slf4j.MDC
类名称:MDC
方法名:clear
[英]Clear all entries in the MDC of the underlying implementation.
[中]清除底层实现的MDC中的所有条目。
代码示例来源:origin: Activiti/Activiti
public static void clear() {
MDC.clear();
}
}
代码示例来源:origin: apache/hive
/**
* Unregister logging context
*/
public static void unregisterLoggingContext() {
MDC.clear();
}
代码示例来源:origin: wildfly/wildfly
public void clearMdc() {
MDC.clear();
}
代码示例来源:origin: org.slf4j/log4j-over-slf4j
public static void clear() {
org.slf4j.MDC.clear();
}
代码示例来源:origin: apache/hive
private void handleLogOnQueryCompletion(String queryIdString, String dagIdString) {
if (routeBasedLoggingEnabled) {
// Inform the routing purgePolicy.
// Send out a fake log message at the ERROR level with the MDC for this query setup. With an
// LLAP custom appender this message will not be logged.
MDC.put("dagId", dagIdString);
MDC.put("queryId", queryIdString);
try {
LOG.error(QUERY_COMPLETE_MARKER, "Ignore this. Log line to interact with logger." +
" Query complete: " + queryIdString + ", " +
dagIdString);
} finally {
MDC.clear();
}
}
}
代码示例来源:origin: apache/hive
@Override
public void close() throws IOException {
if (LlapIoImpl.LOG.isTraceEnabled()) {
LlapIoImpl.LOG.trace("close called; closed {}, interrupted {}, err {}, pending {}",
isClosed, isInterrupted, pendingError.get(), queue.size());
}
LlapIoImpl.LOG.info("Maximum queue length observed " + maxQueueSize);
LlapIoImpl.LOG.info("Llap counters: {}" , counters); // This is where counters are logged!
feedback.stop();
isClosed = true;
rethrowErrorIfAny(pendingError.get());
MDC.clear();
}
代码示例来源:origin: SonarSource/sonarqube
@After
public void cleanMDC() {
MDC.clear();
}
代码示例来源:origin: zalando/zalenium
/**
* @see GridRegistry#addNewSessionRequest(RequestHandler)
*/
public void addNewSessionRequest(RequestHandler handler) {
try {
lock.lock();
Map<String, Object> requestedCapabilities = handler.getRequest().getDesiredCapabilities();
proxies.verifyAbilityToHandleDesiredCapabilities(requestedCapabilities);
requestedCapabilities.forEach((k, v) -> MDC.put(k,v.toString()));
LOG.info("Adding sessionRequest for " + requestedCapabilities.toString());
newSessionQueue.add(handler);
seleniumTestSessionsWaiting.inc();
fireMatcherStateChanged();
} finally {
MDC.clear();
lock.unlock();
}
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public void run() {
Map<String, String> originalContext = MDC.getCopyOfContextMap();
if (context != null) {
MDC.setContextMap(context);
}
try {
this.runnable.run();
} finally {
if (originalContext != null) {
MDC.setContextMap(originalContext);
} else {
MDC.clear();
}
}
}
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public T call() throws Exception {
T answer;
Map<String, String> originalContext = MDC.getCopyOfContextMap();
if (context != null) {
MDC.setContextMap(context);
}
try {
answer = this.callable.call();
} finally {
if (originalContext != null) {
MDC.setContextMap(originalContext);
} else {
MDC.clear();
}
}
return answer;
}
}
代码示例来源:origin: zalando/zalenium
MDC.put("numberOfParallelCloudSessions",String.valueOf(numberOfParallelCloudSessions));
logger.info("Currently using " + numberOfParallelCloudSessions + " parallel sessions . Trying to start one more.");
MDC.clear();
代码示例来源:origin: apache/incubator-druid
MDC.setContextMap(mdc);
} else {
MDC.clear();
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Test
public void testEventLogger() {
logger.info(marker, "This is a test");
MDC.clear();
verify("EventLogger", "o.a.l.s.OptionalTest This is a test" + Strings.LINE_SEPARATOR);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Test
public void mdc() {
MDC.put("TestYear", "2010");
logger.debug("Debug message");
verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Strings.LINE_SEPARATOR);
MDC.clear();
logger.debug("Debug message");
verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Strings.LINE_SEPARATOR);
}
代码示例来源:origin: apache/hive
@Override
public V call() throws Exception {
Thread thread = Thread.currentThread();
// setup uncaught exception handler for the current thread
if (uncaughtExceptionHandler != null) {
thread.setUncaughtExceptionHandler(uncaughtExceptionHandler);
}
// clone thread local file system statistics
List<LlapUtil.StatisticsData> statsBefore = LlapUtil.cloneThreadLocalFileSystemStatistics();
long cpuTime = mxBean == null ? -1 : mxBean.getCurrentThreadCpuTime(),
userTime = mxBean == null ? -1 : mxBean.getCurrentThreadUserTime();
setupMDCFromNDC(actualCallable);
try {
return actualCallable.call();
} finally {
if (mxBean != null) {
cpuTime = mxBean.getCurrentThreadCpuTime() - cpuTime;
userTime = mxBean.getCurrentThreadUserTime() - userTime;
}
updateCounters(statsBefore, actualCallable, cpuTime, userTime);
MDC.clear();
}
}
代码示例来源:origin: stagemonitor/stagemonitor
@After
public void tearDown() throws Exception {
Stagemonitor.reset();
MDC.clear();
}
代码示例来源:origin: apache/incubator-gobblin
MDC.setContextMap(originalContext);
} else {
MDC.clear();
代码示例来源:origin: line/armeria
@Before
public void setUp() {
rootLogger.getLoggerContext().getStatusManager().clear();
MDC.clear();
testLogger = (Logger) LoggerFactory.getLogger("loggerTest." + testName.getMethodName());
testLogger.setLevel(Level.ALL);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Test
public void testEventLogger() {
MDC.put("loginId", "JohnDoe");
MDC.put("ipAddress", "192.168.0.120");
MDC.put("locale", Locale.US.getDisplayName());
final EventData data = new EventData();
data.setEventType("Transfer");
data.setEventId("Audit@18060");
data.setMessage("Transfer Complete");
data.put("ToAccount", "123456");
data.put("FromAccount", "123457");
data.put("Amount", "200.00");
EventLogger.logEvent(data);
MDC.clear();
verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Strings.LINE_SEPARATOR);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Before
@After
public void cleanup() {
MDC.clear();
ctx.getListAppender("List").clear();
ctx.getListAppender("EventLogger").clear();
}
}
内容来源于网络,如有侵权,请联系作者删除!