public void push(PropertyPath path) { pathStack.addFirst( path ); MDC.put( MDC_KEY, extractFullPath( path ) ); }
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(); } }
@Override public void finish() { propertyPathStack.pop(); MDC.remove( MDC_KEY ); fetchSourceStack.clear(); }
private void logAfterComplete(ChannelFuture future, AccessLoggingHeader header, int responseBytes, String status) { String remoteAddress = ((InetSocketAddress)future.channel().remoteAddress()).getHostString(); future.addListener(f -> { // Duration long duration; if (header.requestStart == null) { duration = -1; } else { duration = ChronoUnit.MILLIS.between(header.requestStart, ZonedDateTime.now()); } MDC.clear(); MDC.put("address", remoteAddress); MDC.put("user", checkForNull(header.principalName)); MDC.put("method", checkForNull(header.getOp())); MDC.put("protocol", checkForNull(HotRodVersion.forVersion(header.getVersion()))); MDC.put("status", checkForNull(status)); MDC.put("responseSize", responseBytes); MDC.put("requestSize", header.requestBytes); MDC.put("duration", duration); log.tracef("/%s/%s", checkForNull(header.getCacheName()), checkForNull(header.key)); }); }
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 get(String key) { return (String) MDC.get(key); }
/** * {@inheritDoc} */ @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null) { MDC.put("username", authentication.getPrincipal()); } filterChain.doFilter(servletRequest, servletResponse); MDC.remove("username"); }
public Map getCopyOfContextMap() { return MDC.getMap(); }
public String convert(LogRecord event) { // For now, we rely on the thread local Object val = MDC.get(key); if (val == null) { return null; } else { return val.toString(); } } }
public void pop() { pathStack.removeFirst(); PropertyPath newHead = pathStack.peekFirst(); MDC.put( MDC_KEY, extractFullPath( newHead ) ); } }
/** * {@inheritDoc} */ @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null) { MDC.put("username", authentication.getPrincipal()); } filterChain.doFilter(servletRequest, servletResponse); MDC.remove("username"); }
public void clear() { Map map = MDC.getMap(); if (map != null) map.clear(); }
public void put(String key, String val) { MDC.put(key, val); }
@Override public void removeMdc(String key) { MDC.remove(key); }
@Override public void push(NavigablePath navigablePath) { assert navigablePath != null; internalStack.push( navigablePath ); MDC.put( MDC_KEY, navigablePath.getFullPath() ); }
public void remove(String key) { MDC.remove(key); }
public static ProcessController start(String[] args) throws IOException { MDC.put("process", "process controller");