public Object processInvocation(final InterceptorContext context) throws Exception { final Map<String, Object> mdc = MDC.getMap(); if(mdc != null){ context.putPrivateData(KEY, new StoredLogDiagnosticContext(mdc, NDC.get())); try { return context.proceed(); } finally { context.putPrivateData(KEY, null); } } else { return context.proceed(); } } }
public String convert(LogRecord event) { switch (type) { case RELATIVE_TIME_CONVERTER: return (Long.toString(event.getMillis() - startTime)); case THREAD_CONVERTER: StringBuffer tmp = new StringBuffer("tid("); tmp.append(event.getThreadID()); tmp.append(')'); return tmp.toString(); case THREAD_NAME_CONVERTER: // @todo figure how to map the thread id to its name return "null"; case LEVEL_CONVERTER: return event.getLevel().toString(); case NDC_CONVERTER: // For now rely on the thread local return NDC.get(); case MESSAGE_CONVERTER: { return event.getMessage(); } default: return null; } } }