Java Code Examples for org.apache.log4j.MDC#clear()

The following examples show how to use org.apache.log4j.MDC#clear() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuditFileSpool.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	try {
		//This is done to clear the MDC context to avoid issue with Ranger Auditing for Knox
		MDC.clear();
		runLogAudit();
	} catch (Throwable t) {
		logger.fatal("Exited thread without abnormaly. queue="
				+ consumerProvider.getName(), t);
	}
}
 
Example 2
Source File: AuditBatchQueue.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	try {
		//This is done to clear the MDC context to avoid issue with Ranger Auditing for Knox
		MDC.clear();
		runLogAudit();
	} catch (Throwable t) {
		logger.fatal("Exited thread abnormaly. queue=" + getName(), t);
	}
}
 
Example 3
Source File: AuditSummaryQueue.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	try {
		//This is done to clear the MDC context to avoid issue with Ranger Auditing for Knox
		MDC.clear();
		runLogAudit();
	} catch (Throwable t) {
		logger.fatal("Exited thread without abnormaly. queue=" + getName(),
				t);
	}
}
 
Example 4
Source File: AuditFileCacheProviderSpool.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    try {
        //This is done to clear the MDC context to avoid issue with Ranger Auditing for Knox
        MDC.clear();
        runLogAudit();
    } catch (Throwable t) {
        logger.fatal("Exited thread without abnormaly. queue="
                + consumerProvider.getName(), t);
    }
}
 
Example 5
Source File: AuditAsyncQueue.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	try {
		//This is done to clear the MDC context to avoid issue with Ranger Auditing for Knox
		MDC.clear();
		runLogAudit();
	} catch (Throwable t) {
		logger.fatal("Exited thread abnormaly. queue=" + getName(), t);
	}
}
 
Example 6
Source File: Log4JContextClearingFilter.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Clear Log4J threadlocals
 */
protected static void clearLog4JThreadLocals() {
    NDC.remove();
    MDC.clear();
    ThreadLocal tl = getMDCThreadLocal();
    if (tl != null) {
        tl.remove();
    }
}
 
Example 7
Source File: LogContext.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
public static void unregister() {
    LogContext context = s_currentContext.get();
    if (context != null) {
        s_currentContext.remove();
        if (s_logger.isTraceEnabled()) {
            s_logger.trace("Unregistered: " + context);
        }
    }
    MDC.clear();
}
 
Example 8
Source File: Log4jEcsLayoutTest.java    From ecs-logging-java with Apache License 2.0 4 votes vote down vote up
@BeforeEach
@AfterEach
void tearDown() {
    MDC.clear();
    NDC.clear();
}
 
Example 9
Source File: Log4j1MsgIdHolder.java    From xian with Apache License 2.0 4 votes vote down vote up
@Override
protected void clear0() {
    MDC.clear();
}
 
Example 10
Source File: DefaultConsoleAppenderTest.java    From lambda-monitoring with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
    MDC.clear();
}
 
Example 11
Source File: Tracing.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * clears the tread local data at the end of the request and *MUST* be called
 */
public static void clearLogRequestInfo() {
    MDC.clear();
}
 
Example 12
Source File: Tracing.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * clears the tread local data at the end of the request and *MUST* be called
 */
public static void clearLogRequestInfo() {
    MDC.clear();
}
 
Example 13
Source File: Log4JRunnable.java    From tutorials with MIT License 3 votes vote down vote up
public void run() {

        MDC.put("transaction.id", tx.getTransactionId());
        MDC.put("transaction.owner", tx.getSender());

        log4jBusinessService.transfer(tx.getAmount());

        MDC.clear();

    }