当前位置: 首页>>代码示例>>Java>>正文


Java MDC.setContextMap方法代码示例

本文整理汇总了Java中org.slf4j.MDC.setContextMap方法的典型用法代码示例。如果您正苦于以下问题:Java MDC.setContextMap方法的具体用法?Java MDC.setContextMap怎么用?Java MDC.setContextMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.slf4j.MDC的用法示例。


在下文中一共展示了MDC.setContextMap方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handler

import org.slf4j.MDC; //导入方法依赖的package包/类
public void handler(CloudwatchEvent event) throws ExecutionException, InterruptedException {
    LOG.info("Received event = [{}]", event.getId());
    final Metrics metrics = new Metrics();

    // Pass Mapped Diagnostic Context (MDC) into child thread, for logging Request ID
    final Map<String, String> contextMap = MDC.getCopyOfContextMap();
    Runnable task = () -> {
        if (contextMap != null) {
            MDC.setContextMap(contextMap);
        }
        LOG.info("Starting fibonacci task");
        timedFibonacci(metrics);
    };

    // Start one task in the background, and one in this thread
    Future<?> future = executorService.submit(task);
    task.run();

    // Wait for background task, log out metrics
    future.get();
    metrics.report(LOG);
}
 
开发者ID:symphoniacloud,项目名称:jvm-perftest-lambda,代码行数:23,代码来源:FibonacciLambda.java

示例2: call

import org.slf4j.MDC; //导入方法依赖的package包/类
public T call() throws Exception {
  MDC.setContextMap(contextMap);
  try {
    return target.call();
  }
  finally {
    MDC.clear();
  }
}
 
开发者ID:zacharee,项目名称:RCTDRemoverforLG,代码行数:10,代码来源:MDCCallableAdapter.java

示例3: call

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public K call() throws Exception {
    LOG.debug("Call using MDCHystrixContextCallable...");
    Map childMDC = MDC.getCopyOfContextMap();
    LOG.debug("childMDC --> " + childMDC);
    try {
        if (parentMDC != null) {
            MDC.setContextMap(parentMDC);
        }
        LOG.debug("parentMDC --> " + parentMDC);
        return actual.call();
    } finally {
        if (childMDC != null) {
            MDC.setContextMap(childMDC);
        }
    }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:18,代码来源:MDCConcurrentCallable.java

示例4: run

import org.slf4j.MDC; //导入方法依赖的package包/类
public void run() {
  MDC.setContextMap(contextMap);
  try {
    target.run();
  }
  finally {
    MDC.clear();
  }
}
 
开发者ID:zacharee,项目名称:RCTDRemoverforLG,代码行数:10,代码来源:MDCRunnableAdapter.java

示例5: decorate

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public Runnable decorate(Runnable runnable) {
    Map<String, String> contextMap = MDC.getCopyOfContextMap();
    return () -> {
        try {
            MDC.setContextMap(contextMap);
            runnable.run();
        } finally {
            MDC.clear();
        }
    };
}
 
开发者ID:redhat-developer,项目名称:che-starter,代码行数:13,代码来源:MdcTaskDecorator.java

示例6: run

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public void run() {
    RequestContextAccessor.set(requestContext);

    if (mdcContents != null) {
        MDC.setContextMap(mdcContents);
    }

    runnable.run();

    MDC.clear();
    RequestContextAccessor.remove();
}
 
开发者ID:Atypon-OpenSource,项目名称:wayf-cloud,代码行数:14,代码来源:WayfRunnable.java

示例7: run

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public void run() {
	// we are in the execution thread: set the original MDC
	MDC.setContextMap(map);
	wrapped.run();
}
 
开发者ID:Orange-OpenSource,项目名称:orange-mathoms-logging,代码行数:7,代码来源:RunnableWrapperWithMdc.java

示例8: call

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public T call() throws Exception {
	// we are in the execution thread: set the original MDC
	MDC.setContextMap(map);
	return wrapped.call();
}
 
开发者ID:Orange-OpenSource,项目名称:orange-mathoms-logging,代码行数:7,代码来源:CallableWrapperWithMdc.java


注:本文中的org.slf4j.MDC.setContextMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。