當前位置: 首頁>>代碼示例>>Java>>正文


Java MDC.remove方法代碼示例

本文整理匯總了Java中org.apache.log4j.MDC.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java MDC.remove方法的具體用法?Java MDC.remove怎麽用?Java MDC.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.MDC的用法示例。


在下文中一共展示了MDC.remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unsetLoggingContext

import org.apache.log4j.MDC; //導入方法依賴的package包/類
/**
 * Remove the elements from the Message Driven Context (MDC) of Log4J, that may have been added by the call to setLoggingContext().
 */
public static void unsetLoggingContext() {
    Stack<Map<String, Object>> stack = t_loggingContext.get();
    if (stack == null || stack.size() == 0)
        throw new UnsupportedOperationException("The unsetLoggingContext() method can only be called after a setLoggingContext()");

    // Remove the current context
    if (MDC.getContext() != null) {
        Set<String> keys = new HashSet<String>(MDC.getContext().keySet());
        for (String key : keys)
            MDC.remove(key);
    }

    // Now add the elements of the previous logging context into the MDC
    Map<String, Object> previousLoggingContext = stack.pop();
    for (Map.Entry<String, Object> me : previousLoggingContext.entrySet())
        MDC.put(me.getKey(), me.getValue());
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:21,代碼來源:LoggingService.java

示例2: unsetLoggingContext

import org.apache.log4j.MDC; //導入方法依賴的package包/類
/** Remove the elements from the Message Driven Context (MDC) of Log4J, that may have been added by the call to setLoggingContext().
 * @param payload Any serializable object.
 * @param messageInfo the corresponding MessageInfo object, as specified in the configuration file.
 */
public static void unsetLoggingContext(Object payload, MessageInfo messageInfo) {
    Stack<Map<String, Object>> stack = t_loggingContext.get();
    if (stack == null || stack.size() == 0)
        throw new UnsupportedOperationException("The unsetLoggingContext() method can only be called after a setLoggingContext()");

    // Remove the current context
    if (MDC.getContext() != null) {
        Set<String> keys = new HashSet<String>(MDC.getContext().keySet());
        for (String key : keys)
            MDC.remove(key);
    }

    // Now add the elements of the previous logging context into the MDC
    Map<String, Object> previousLoggingContext = stack.pop();
    for (Map.Entry<String, Object> me : previousLoggingContext.entrySet())
        MDC.put(me.getKey(), me.getValue());
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:22,代碼來源:LoggingService.java

示例3: indexDocument

import org.apache.log4j.MDC; //導入方法依賴的package包/類
@Override
public void indexDocument(String documentId) {
    if (StringUtils.isBlank(documentId)) {
        throw new RiceIllegalArgumentException("documentId was null or blank");
    }
    MDC.put("docId", documentId);
    try {
        long t1 = System.currentTimeMillis();
        LOG.info("Indexing document attributes for document " + documentId);
        Document document = getWorkflowDocumentService().getDocument(documentId);
        if (document == null) {
            throw new RiceIllegalArgumentException("Failed to locate document with the given id: " + documentId);
        }
        DocumentContent documentContent =
                KewApiServiceLocator.getWorkflowDocumentService().getDocumentContent(documentId);
        List<SearchableAttributeValue> attributes = buildSearchableAttributeValues(document, documentContent);
        KEWServiceLocator.getRouteHeaderService().updateRouteHeaderSearchValues(documentId, attributes);
        long t2 = System.currentTimeMillis();
        LOG.info("...finished indexing document " + documentId + " for document search, total time = " + (t2 - t1) +
                " ms.");
    } finally {
        MDC.remove("docId");
    }
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:25,代碼來源:DocumentAttributeIndexingQueueImpl.java

示例4: testMdc

import org.apache.log4j.MDC; //導入方法依賴的package包/類
/**
 * This is a test for
 * <a href="http://jira.pentaho.com/browse/MONDRIAN-994">MONDRIAN-994</a>.
 * It checks that the MDC logging context is passed through all the
 * threads.
 */
public void testMdc() {
    final TestContext context =
        udfTestContext(
            "<UserDefinedFunction name=\"Mdc\" className=\""
            + MdcUdf.class.getName()
            + "\"/>\n");
    MDC.put(MDC_KEY, MDC_OBJECT);
    try {
        context.executeQuery(
            "with member [Measures].[MDC] as 'Mdc([Measures].[Unit Sales])' "
            + "select {[Measures].[MDC]} on columns from [Sales]");
    } finally {
        MDC.remove(MDC_KEY);
    }
}
 
開發者ID:OSBI,項目名稱:mondrian,代碼行數:22,代碼來源:UdfTest.java

示例5: unsetContext

import org.apache.log4j.MDC; //導入方法依賴的package包/類
/**
 * Unsets context information from Log4J's MDC object.
 * if a SubProcessName exists, them simply remove SubProcessName from MDC
 * However, if the SubProcessName doesn't exists, then remove ProcessName from MDC
 */
protected void unsetContext() {
    if(MDC.get(BusinessEventLogMeta.SUB_PROCESS_NAME)!=null)
        MDC.remove(BusinessEventLogMeta.SUB_PROCESS_NAME);
    else
        MDC.remove(BusinessEventLogMeta.PROCESS_NAME);
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:12,代碼來源:GraphService.java

示例6: cleanupLog4jMdc

import org.apache.log4j.MDC; //導入方法依賴的package包/類
/** This method cleans up the Mapped Diagnostic Context (MDC) in Log4J.
 * It is invoked only if the setupLog4jMdc() had successfully created the MDC.
 */
protected void cleanupLog4jMdc() {
    if (log.isDebugEnabled())
        log.debug("Cleaning log4j.MDC");
    MDC.remove(MDC_USER_ID);
    MDC.remove(MDC_IP);
    MDC.remove(MDC_COMPONENT_ID);
    MDC.remove(MDC_EVENT_ID);
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:12,代碼來源:PortletFilter.java

示例7: discardTransactionInfo

import org.apache.log4j.MDC; //導入方法依賴的package包/類
/**
 * This API is used for removing trasaction information from logs
 */
public final void discardTransactionInfo() {

  if (enabled) {

    /* Remove internal transaction id information in MDC */
    MDC.remove(intTransIdConst);

    /* Remove external transaction id inform in MDC */
    MDC.remove(extTransIdConst);
  }
}
 
開發者ID:inbravo,項目名稱:scribe,代碼行數:15,代碼來源:MutualDiagnosticLogUtils.java

示例8: close

import org.apache.log4j.MDC; //導入方法依賴的package包/類
@Override
public void close()  {
    while (!keys.empty()) {
        Key key = keys.pop();
        if (key.getOldValue() != null) MDC.put(key.getKey(), key.getOldValue());
        else MDC.remove(key.getKey());

    }
}
 
開發者ID:andyphillips404,項目名稱:awplab-core,代碼行數:10,代碼來源:MDCAutoClosable.java

示例9: close

import org.apache.log4j.MDC; //導入方法依賴的package包/類
@Override
public void close() {
    if (oldLoggingLevels == null) {
        MDC.remove(Log.MDC_KEY_LOGGER_LEVELS);
    }
    else {
        MDC.put(Log.MDC_KEY_LOGGER_LEVELS, oldLoggingLevels);
    }
}
 
開發者ID:andyphillips404,項目名稱:awplab-core,代碼行數:10,代碼來源:MDCLoggerLevelsAutoClosable.java

示例10: doFilter

import org.apache.log4j.MDC; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
	HttpServletRequest httpRequest = (HttpServletRequest) request;
	HttpSession session = httpRequest.getSession();
	boolean setUserId = false;
	if ( session != null && session.getAttribute(Constants.SESS_ACCOUNT) != null ) {
		String accountId = ((AccountObj)session.getAttribute(Constants.SESS_ACCOUNT)).getAccount();
		MDC.put(_USERID_KEY_NAME, accountId);
		setUserId = true;
	}
	if (!setUserId) {
		String url = httpRequest.getRequestURL().toString();
		if (url.indexOf("/services/") > -1) {
			MDC.put(_USERID_KEY_NAME, "CXF-WEBSERVICE");
			setUserId = true;
		}
		if (url.indexOf("/camel/") > -1) {
			MDC.put(_USERID_KEY_NAME, "CAMEL-ESB");
			setUserId = true;
		}
	}
	try {
		chain.doFilter(request, response);
	} catch (ServletException | IOException e) {
		e.printStackTrace();
	} finally {
		if (setUserId) {
			MDC.remove(_USERID_KEY_NAME);
		}
	}
}
 
開發者ID:billchen198318,項目名稱:bamboobsc,代碼行數:32,代碼來源:MDCUserServletFilter.java

示例11: trace

import org.apache.log4j.MDC; //導入方法依賴的package包/類
public void trace(TaskId id, String message) {
    if (logger.isTraceEnabled()) {
        updateMdcWithTaskLogFilename(id);
        logger.trace(format(id, message));
        MDC.remove(FileAppender.FILE_NAME);
    }
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:8,代碼來源:TaskLogger.java

示例12: decideInvalidJson

import org.apache.log4j.MDC; //導入方法依賴的package包/類
@Test
public void decideInvalidJson() throws IOException {
    LoggingEvent loggingEvent = new LoggingEvent();
    loggingEvent.setMessage(readFirstLine("/invalid-json.json"));
    try {
        FilterReply reply = jsonValidationFilter.decide(loggingEvent);
        assertThat(reply, is(FilterReply.DENY));
        assertThat(MDC.get(OutputValidationException.MDC_KEY), notNullValue());
    }finally {
        MDC.remove(OutputValidationException.MDC_KEY);
    }
}
 
開發者ID:CiscoCTA,項目名稱:taxii-log-adapter,代碼行數:13,代碼來源:JsonValidationFilterTest.java

示例13: handleCaptureEndRequest

import org.apache.log4j.MDC; //導入方法依賴的package包/類
private void handleCaptureEndRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	String room = request.getParameter("room");
	String seqNum = request.getParameter("sequenceNumber");
	MDC.put("meetingId", room);
	log.debug("handleCaptureEndRequest - room: {} seq: {}", new Object[] { room, seqNum });
	MDC.remove("meetingId");
	sessionManager.removeSession(room, Integer.valueOf(seqNum));
}
 
開發者ID:BigMarker,項目名稱:deskshare-public,代碼行數:9,代碼來源:StreamControllerServlet.java

示例14: handleUpdateMouseLocationRequest

import org.apache.log4j.MDC; //導入方法依賴的package包/類
private void handleUpdateMouseLocationRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	String room = request.getParameter("room");
	String mouseX = request.getParameter("mousex");
	String mouseY = request.getParameter("mousey");
	String seqNum = request.getParameter("sequenceNumber");
	MDC.put("meetingId", room);
	log.debug("handleUpdateMouseLocationRequest - room: {} seq: {} pos: {}x{}", new Object[] { room, seqNum, mouseX, mouseY });
	MDC.remove("meetingId");
	sessionManager.updateMouseLocation(room, Integer.valueOf(mouseX), Integer.valueOf(mouseY), Integer.valueOf(seqNum));
}
 
開發者ID:BigMarker,項目名稱:deskshare-public,代碼行數:11,代碼來源:StreamControllerServlet.java

示例15: handleExit

import org.apache.log4j.MDC; //導入方法依賴的package包/類
private void handleExit(HttpServletRequest request, HttpServletResponse response) throws Exception {
	String room = request.getParameter("room");
	MDC.put("meetingId", room);
	log.debug("handleExit - room: {}", room);
	MDC.remove("meetingId");
	sessionManager.exit(room);
}
 
開發者ID:BigMarker,項目名稱:deskshare-public,代碼行數:8,代碼來源:StreamControllerServlet.java


注:本文中的org.apache.log4j.MDC.remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。