Source:
<code>protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { final long start = System.currentTimeMillis(); try { filterChain.doFilter(request, response); } finally { final long time = System.currentTimeMillis(); final Long timing = time - start; final String userAgent = Optional.ofNullable(request.getHeader("User-Agent")).orElse("-"); final String user = Optional.ofNullable(request.getUserPrincipal()).map(Principal::getName).orElse("-"); final String method = request.getMethod(); final String path = request.getRequestURI(); final String query = Optional.ofNullable(request.getQueryString()).map(q -> "?" + q).orElse(""); final String contentEncoding = Optional.ofNullable(request.getHeader(HttpHeaders.CONTENT_ENCODING)) .orElse("-"); final String acceptEncoding = Optional.ofNullable(request.getHeader(HttpHeaders.ACCEPT_ENCODING)) .orElse("-"); final Long contentLength = request.getContentLengthLong() == -1 ? 0 : request.getContentLengthLong(); <START> ACCESS_LOGGER.info("[ACCESS_LOG] \"{}{}\" \"{}\" \"{}\" statusCode: ms \"{}\" \"{}\" bytes", <END> method, path, query, userAgent, user, response.getStatus(), timing, contentEncoding, acceptEncoding, contentLength); nakadiKpiPublisher.publish(accessLogEventType, () -> new JSONObject() .put("method", method) .put("path", path) .put("query", query) .put("app", user) .put("app_hashed", nakadiKpiPublisher.hash(user)) .put("status_code", response.getStatus()) .put("response_time_ms", timing)); } }</code><technical_language>@antban 1) I another quick win [ACCESS_LOG] string shorter 2) remove statusCode: string parser extract actual 3) replace bytes B</technical_language>

Target:
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { final long start = System.currentTimeMillis(); try { filterChain.doFilter(request, response); } finally { final long time = System.currentTimeMillis(); final Long timing = time - start; final String userAgent = Optional.ofNullable(request.getHeader("User-Agent")).orElse("-"); final String user = Optional.ofNullable(request.getUserPrincipal()).map(Principal::getName).orElse("-"); final String method = request.getMethod(); final String path = request.getRequestURI(); final String query = Optional.ofNullable(request.getQueryString()).map(q -> "?" + q).orElse(""); final String contentEncoding = Optional.ofNullable(request.getHeader(HttpHeaders.CONTENT_ENCODING)) .orElse("-"); final String acceptEncoding = Optional.ofNullable(request.getHeader(HttpHeaders.ACCEPT_ENCODING)) .orElse("-"); final Long contentLength = request.getContentLengthLong() == -1 ? 0 : request.getContentLengthLong(); ACCESS_LOGGER.info("{} \"{}{}\" \"{}\" \"{}\" {}ms \"{}\" \"{}\" {}B", method, path, query, userAgent, user, response.getStatus(), timing, contentEncoding, acceptEncoding, contentLength); nakadiKpiPublisher.publish(accessLogEventType, () -> new JSONObject() .put("method", method) .put("path", path) .put("query", query) .put("app", user) .put("app_hashed", nakadiKpiPublisher.hash(user)) .put("status_code", response.getStatus()) .put("response_time_ms", timing)); } }