当前位置: 首页>>代码示例>>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;未经允许,请勿转载。