public Object processInvocation(final InterceptorContext context) throws Exception { final Map<String, Object> mdc = MDC.getMap(); if (mdc != null) { for (String str : mdc.keySet()) { MDC.remove(str); } } final StoredLogDiagnosticContext data = (StoredLogDiagnosticContext) context.getPrivateData(KEY); context.putPrivateData(KEY, null); if (data != null && data.getMdc() != null) { for (Map.Entry<String, Object> entry : data.getMdc().entrySet()) { MDC.put(entry.getKey(), entry.getValue()); } final int depth = NDC.getDepth(); NDC.push(data.getNdc()); try { return context.proceed(); } finally { NDC.setMaxDepth(depth); for (String str : MDC.getMap().keySet()) { MDC.remove(str); } } } return context.proceed(); } }
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 Map getCopyOfContextMap() { return MDC.getMap(); }
public void clear() { Map map = MDC.getMap(); if (map != null) map.clear(); }