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)); }); }