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


Java MDC.get方法代码示例

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


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

示例1: getCorrelationId

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public String getCorrelationId() {
  HttpHeaders headers = ResteasyProviderFactory.getContextData(HttpHeaders.class);

  String correlationId;
  if (headers != null) {
    correlationId = headers.getHeaderString(headerName);
    if (correlationId != null) {
      return correlationId;
    }
  }

  // Fall back to MDC to support beadledom-jaxrs 1.0. Retrieving from the headers is preferred.
  correlationId = MDC.get(mdcName);

  return correlationId;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:18,代码来源:ResteasyCorrelationIdContext.java

示例2: ErrorResponse

import org.slf4j.MDC; //导入方法依赖的package包/类
/**
 * Creates an error response with just the error code and description. The
 * request ID will be taken from the MDC.
 *
 * @param error
 *            error code
 * @param errorDescription
 *            error description
 */
public ErrorResponse(final String error,
    final String errorDescription) {

    this.error = error;
    this.errorDescription = errorDescription;
    requestId = MDC.get(REQUEST_ID);

    cause = null;
    errorClass = null;
    host = MDC.get(MDCKeys.HOST);
    jwtId = MDC.get(MDCKeys.JWT_ID);
    stackTrace = null;
    threadId = Thread.currentThread().getName();
    requestUri = calculateRequestUri();
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:25,代码来源:ErrorResponse.java

示例3: pushMDC

import org.slf4j.MDC; //导入方法依赖的package包/类
@Nonnull
public LogContext pushMDC(@Nonnull final String key, @Nullable final String value) {
    if (mdcStack == null) {
        mdcStack = new LinkedList<>();
    }

    final String old = MDC.get(key);
    mdcStack.push(new MDCEntry(key, old));
    MDC.put(key, value);

    return this;
}
 
开发者ID:ivnik,项目名称:smartlog,代码行数:13,代码来源:LogContext.java

示例4: getProperty

import org.slf4j.MDC; //导入方法依赖的package包/类
public static String getProperty(IoSession session, String key) {
    if (key == null) {
        throw new IllegalArgumentException("key should not be null");
    }

    Map<String, String> context = getContext(session);
    String answer = context.get(key);
    if (answer != null) {
        return answer;
    }

    return MDC.get(key);
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:14,代码来源:MdcInjectionFilter.java

示例5: calculateRequestUri

import org.slf4j.MDC; //导入方法依赖的package包/类
/**
 * Performs a null-check on the request URI data.
 *
 * @return request URI
 */
private URI calculateRequestUri() {

    final String requestUriString = MDC.get(MDCKeys.REQUEST_URI);
    if (requestUriString == null) {

        return null;
    } else {
        return URI.create(requestUriString);
    }
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:16,代码来源:ErrorResponse.java

示例6: handle

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
	for (Entry<String, String> e : mdcName2HeaderName.entrySet()) {
		String mdcValue = MDC.get(e.getKey());
		if (mdcValue != null) {
			request.addHeader(new BasicHeader(e.getValue(), mdcValue));
		}
	}
}
 
开发者ID:Orange-OpenSource,项目名称:orange-mathoms-logging,代码行数:10,代码来源:HttpRequestHandlerWithMdcPropagation.java

示例7: stopTestLogging

import org.slf4j.MDC; //导入方法依赖的package包/类
/**
 * Removes the key (log file name) from MDC
 * 
 * @return name of the log file, if one existed in MDC
 */
public static String stopTestLogging()
{
    final String name = MDC.get(TEST_NAME);
    MDC.remove(TEST_NAME);
    return name;
}
 
开发者ID:pradeeptaswain,项目名称:oldmonk,代码行数:12,代码来源:LoggerUtils.java

示例8: log

import org.slf4j.MDC; //导入方法依赖的package包/类
/**
 * Logs the HTTP status code and exception in HttpFSServer's log.
 *
 * @param status HTTP status code.
 * @param throwable exception thrown.
 */
@Override
protected void log(Response.Status status, Throwable throwable) {
  String method = MDC.get("method");
  String path = MDC.get("path");
  String message = getOneLineMessage(throwable);
  AUDIT_LOG.warn("FAILED [{}:{}] response [{}] {}", new Object[]{method, path, status, message});
  LOG.warn("[{}:{}] response [{}] {}", new Object[]{method, path, status, message}, throwable);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:HttpFSExceptionProvider.java

示例9: filter

import org.slf4j.MDC; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
    String requestId = MDC.get(Constants.X_OBOS_REQUEST_ID);
    if (requestId != null) {
        requestContext.getHeaders().putSingle(Constants.X_OBOS_REQUEST_ID, requestId);
    }
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:8,代码来源:RequestIdClientFilter.java

示例10: getRid

import org.slf4j.MDC; //导入方法依赖的package包/类
public static String getRid() {
    return MDC.get(RID);
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:4,代码来源:MdcUtils.java

示例11: getTimeNs

import org.slf4j.MDC; //导入方法依赖的package包/类
public static long getTimeNs(String key) {
    String time = MDC.get(key + TIME);
    return StringUtils.isNotBlank(time) ? Long.parseLong(time) : 0L;
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:5,代码来源:MdcUtils.java

示例12: getRequestId

import org.slf4j.MDC; //导入方法依赖的package包/类
private String getRequestId() {
    String requestId = MDC.get(REQUEST_ID_MDC_KEY);
    LOG.debug("'X-Request-Id' sent {}", requestId);
    return requestId;
}
 
开发者ID:redhat-developer,项目名称:che-starter,代码行数:6,代码来源:KeycloakInterceptor.java

示例13: run

import org.slf4j.MDC; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Map<Method, Set<Invocation>> run(String patientClassPath, Artifact patient)
		throws IOException, InterruptedException, AnalysisRunFailedException, ClassNotFoundException {
	// create temporary file for output
	Path analysisOutput = Files.createTempFile("kowalski-call-graph-batch-analysis-runner-", ".dat");
	// TODO use G.reset() instead of fork and serialize, make sure only one
	// job runs, start multiple job-vms
	try {
		// TODO jmx, arguments should be escaped
		// -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=1044
		// run command
		String command = String.format(
				"%s -Xmx2g -classpath %s %s -output-format none -allow-phantom-refs -p jb use-original-names --keep-line-number --process-dir %s --soot-class-path %s %s",
				this.java, this.classPath, this.mainClass, patient.getFile().getAbsolutePath(), patientClassPath,
				analysisOutput.toAbsolutePath().toString());
		Process process = Runtime.getRuntime().exec(command);
		String mdcPatient = MDC.get(Reader.PATIENT);
		this.pipe(mdcPatient, process.getInputStream(), LOGGER::debug);
		this.pipe(mdcPatient, process.getErrorStream(), LOGGER::warn);
		if (!process.waitFor(this.timeout, TimeUnit.MILLISECONDS)) {
			LOGGER.error("Killing analysis, took too long");
			process.destroyForcibly();
		}
		// wait and check exit value
		int exitValue = process.waitFor();
		if (exitValue != 0) {
			throw new AnalysisRunFailedException(exitValue, patient);
		}
		// deserialize output
		try (Input input = new Input(Files.newInputStream(analysisOutput))) {
			return (Map<Method, Set<Invocation>>) (new Kryo()).readObject(input,
					(new TypeToken<HashMap<Method, HashSet<Invocation>>>() {

						private static final long serialVersionUID = 1L;

					}).getRawType());
		}
	} finally {
		// delete temporary file
		analysisOutput.toFile().delete();
	}
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:43,代码来源:AnalysisRunner.java

示例14: getSessionId

import org.slf4j.MDC; //导入方法依赖的package包/类
public static String getSessionId() {
    return MDC.get(FIELD_SESSION_ID);
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:4,代码来源:MdcFields.java

示例15: getRootRequestId

import org.slf4j.MDC; //导入方法依赖的package包/类
public static String getRootRequestId() {
    return MDC.get(FIELD_ROOT_REQUEST_ID);
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:4,代码来源:MdcFields.java


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