@Override public String toString() { return String.format("%s - %s [%s] \"%s\" %s %s %s %s %s", toString(clientIP), toString(userName), DEFAULT_DATE_FORMAT.format(date), toString(requestLine), toString(headers), toString(requestBody), toString(responseCode), toString(responseContentLength), toString(responseBody)); }
@Override public String toString() { return String.format("%s - %s [%s] \"%s\" %s %s %s %s %s", toString(clientIP), toString(userName), DEFAULT_DATE_FORMAT.format(date), toString(requestLine), toString(headers), toString(requestBody), toString(responseCode), toString(responseContentLength), toString(responseBody)); }
private void emitAuditLog() { try { AUDIT_LOGGER.trace(logEntry.toString()); } finally { logEntry = null; } } }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String requestLine = request.getMethod() + " " + request.getRequestURI() + " " + request.getProtocol(); AuditLogEntry logEntry = new AuditLogEntry(requestLine, request.getRemoteUser(), InetAddress.getByName(request.getRemoteAddr()).getHostAddress(), Collections.<String, String>emptyMap()); logEntry.setResponse(response.getStatus(), ((Response) response).getContentCount()); logger.trace(logEntry.toString()); } }
private void auditLogIfNeeded(HttpRequest request, HttpResponse response, Channel channel) { if (!auditLogEnabled) { return; } AuditLogEntry logEntry = new AuditLogEntry(request, Networks.getIP(channel.remoteAddress())); logEntry.setResponse(response); AUDIT_LOGGER.trace(logEntry.toString()); }
private void createLogEntry(HttpRequest httpRequest, HttpResponseStatus responseStatus) throws UnknownHostException { InetAddress clientAddr = InetAddress.getByName(Objects.firstNonNull(SecurityRequestContext.getUserIP(), "0.0.0.0")); AuditLogEntry logEntry = new AuditLogEntry(httpRequest, clientAddr.getHostAddress()); logEntry.setUserName(authenticationContext.getPrincipal().getName()); logEntry.setResponse(responseStatus.code(), 0L); AUDIT_LOG.trace(logEntry.toString()); } }
@Override public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) throws Exception { AuditLogEntry logEntry = getLogEntry(ctx); if (!logEntry.isLogged()) { AUDIT_LOG.trace(logEntry.toString()); logEntry.setLogged(true); } }
private void createLogEntry(HttpRequest httpRequest, HttpResponseStatus responseStatus) throws UnknownHostException { InetAddress clientAddr = InetAddress.getByName(Objects.firstNonNull(SecurityRequestContext.getUserIP(), "0.0.0.0")); AuditLogEntry logEntry = new AuditLogEntry(httpRequest, clientAddr.getHostAddress()); logEntry.setUserName(authenticationContext.getPrincipal().getName()); logEntry.setResponse(responseStatus.code(), 0L); AUDIT_LOG.trace(logEntry.toString()); } }