org.apache.log4j.MDC.clear()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(486)

本文整理了Java中org.apache.log4j.MDC.clear()方法的一些代码示例,展示了MDC.clear()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MDC.clear()方法的具体详情如下:
包路径:org.apache.log4j.MDC
类名称:MDC
方法名:clear

MDC.clear介绍

[英]Clear map with key/value in current thread's MDC
[中]清除当前线程MDC中带有键/值的映射

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void clearMdc() {
  MDC.clear();
}

代码示例来源:origin: wildfly/wildfly

public void clearMdc() {
  MDC.clear();
}

代码示例来源:origin: apache/activemq-artemis

public void clearMdc() {
  MDC.clear();
}

代码示例来源:origin: shawntime/shawn-common-utils

private void clearMDC() {
    MDC.clear();
  }
}

代码示例来源:origin: apache/activemq-artemis

public void clearMdc() {
  MDC.clear();
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

public void clearMdc() {
  MDC.clear();
}

代码示例来源:origin: org.tinygroup/org.tinygroup.slf4j-log4j12

public void clear() {
 org.apache.log4j.MDC.clear();
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

public void clearMdc() {
  MDC.clear();
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public void clearMdc() {
  MDC.clear();
}

代码示例来源:origin: tony19/logback-android

@After
public void tearDown() throws Exception {
  lc = null;
  layout = null;
  MDC.clear();
}

代码示例来源:origin: org.rundeck/rundeck-core

protected void log(final Path path, String action, boolean dir, Map<String, String> meta, String status) {
  MDC.put("path", path.toString());
  MDC.put("action", action);
  String metastring = null != meta ? meta.toString() : "-";
  MDC.put("metadata", metastring);
  final String type = dir ? "directory" : "file";
  MDC.put("type", type);
  String statusString = null != status ? status : "-";
  MDC.put("status", statusString);
  logger.info(action +
        ":[" +
        type +
        "]:" +
        String.valueOf(path) +
        ":" +
        (dir ? "" : metastring) +
        ": " +
        statusString);
  MDC.clear();
}

代码示例来源:origin: io.eventcenter/ec-api

throw new RuntimeException(e);
}finally{
  MDC.clear();

代码示例来源:origin: jenkinsci/ssh-steps-plugin

@Override
public final boolean start() {
 Authentication auth = Jenkins.getAuthentication();
 task = getExecutorService().submit(() -> {
  try {
   getContext()
     .onSuccess(ACL.impersonate(auth, new NotReallyRoleSensitiveCallable<T, Exception>() {
      @Override
      public T call() throws Exception {
       threadName = Thread.currentThread().getName();
       MDC.put("execution.id", UUID.randomUUID().toString());
       return SSHStepExecution.this.run();
      }
     }));
  } catch (Exception e) {
   getContext().onFailure(e);
  } finally {
   MDC.clear();
  }
 });
 return false;
}

代码示例来源:origin: com.peterphi.std.guice/stdlib-guice-webapp

MDC.clear();

代码示例来源:origin: brant-hwang/spring-logback-slack-notification-example

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  RequestWrapper requestWrapper = RequestWrapper.of(request);
  // Set Http Header
  MDCUtil.setJsonValue(MDCUtil.HEADER_MAP_MDC, requestWrapper.headerMap());
  // Set Http Body
  MDCUtil.setJsonValue(MDCUtil.PARAMETER_MAP_MDC, requestWrapper.parameterMap());
  // If you use SpringSecurity, you could SpringSecurity UserDetail Information.
  MDCUtil.setJsonValue(MDCUtil.USER_INFO_MDC, HttpUtils.getCurrentUser());
  // Set Agent Detail
  MDCUtil.setJsonValue(MDCUtil.AGENT_DETAIL_MDC, AgentUtils.getAgentDetail((HttpServletRequest) request));
  // Set Http Request URI
  MDCUtil.set(MDCUtil.REQUEST_URI_MDC, requestWrapper.getRequestUri());
  try {
    chain.doFilter(request, response);
  } finally {
    MDC.clear();
  }
}

相关文章