I required kind of the same thing in my app and tested the timeout and FINALIZE_SESSION_MARKER. They both worked fine. I think you are just missing to call the MDC.remove(key) after you are done with an appender. The way I tested it is by listing the appenders every certain time and even logging a late message with goes to the default key.( If you set the timeout to 0 the appender will be cleaned as soon as you call the MDC.remove(key)). I hope it helps. I'm using slf4j-api 1.7.12 + logback 1.1.3. Attached you can see my full example.
MDC.put("batchid",logName.toString());
logger.debug("Processing batch id " + batchid);
logger.debug("Redirecting log to "+ logName.toString());
for(int i=0;i<5;i++){
o2TravelLogger.info("O2Travel record sub {}",i);
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Hi all,
I required kind of the same thing in my app and tested the timeout and FINALIZE_SESSION_MARKER. They both worked fine. I think you are just missing to call the MDC.remove(key) after you are done with an appender. The way I tested it is by listing the appenders every certain time and even logging a late message with goes to the default key.( If you set the timeout to 0 the appender will be cleaned as soon as you call the MDC.remove(key)). I hope it helps. I'm using slf4j-api 1.7.12 + logback 1.1.3. Attached you can see my full example.
MDC.put("batchid",logName.toString());
logger.debug("Processing batch id " + batchid);
logger.debug("Redirecting log to "+ logName.toString());
for(int i=0;i<5;i++){
o2TravelLogger.info("O2Travel record sub {}",i);
Thread.sleep(1000);
}
// o2TravelLogger.info(FINALIZE_SESSION_MARKER, "");
MDC.remove("batchid");
Thread.sleep(5000);
showAppenderTracker();