當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。