Class JBossLoggingAccessLogReceiver

java.lang.Object
io.quarkus.vertx.http.runtime.filters.accesslog.JBossLoggingAccessLogReceiver
All Implemented Interfaces:
AccessLogReceiver

public class JBossLoggingAccessLogReceiver extends Object implements AccessLogReceiver
Access log receiver that logs messages at INFO level via JBoss Logging.

When logMessage(String, RoutingContext) is called, structured request fields are injected into the MDC (backed by Vert.x context-local data when running on a Vert.x thread) under reserved keys (all prefixed with "__access__") so that log formatters such as quarkus-logging-json can emit them as first-class JSON fields. The MDC entries are removed synchronously in a finally block after the log record is created, so they never leak beyond the log call.

Author:
Stuart Douglas
  • Field Details

    • MDC_FIELD_PREFIX

      public static final String MDC_FIELD_PREFIX
      Prefix shared by every MDC key written by this receiver. Consumers (e.g. logging-json) can use this prefix to discover and process structured access-log fields.
      See Also:
    • MDC_METHOD

      public static final String MDC_METHOD
      MDC key for the HTTP request method (e.g. GET).
      See Also:
    • MDC_URI

      public static final String MDC_URI
      MDC key for the request URI, including the query string when present.
      See Also:
    • MDC_STATUS

      public static final String MDC_STATUS
      MDC key for the HTTP response status code (e.g. 200).
      See Also:
    • MDC_RESPONSE_TIME_MS

      public static final String MDC_RESPONSE_TIME_MS
      MDC key for the response time in milliseconds.
      See Also:
    • MDC_BYTES_SENT

      public static final String MDC_BYTES_SENT
      MDC key for the number of bytes sent (excluding HTTP headers).
      See Also:
    • MDC_REMOTE_IP

      public static final String MDC_REMOTE_IP
      MDC key for the remote IP address of the client.
      See Also:
    • MDC_PROTOCOL

      public static final String MDC_PROTOCOL
      MDC key for the HTTP protocol version (e.g. HTTP/1.1).
      See Also:
    • DEFAULT_CATEGORY

      public static final String DEFAULT_CATEGORY
      See Also:
  • Constructor Details

    • JBossLoggingAccessLogReceiver

      public JBossLoggingAccessLogReceiver(String category)
    • JBossLoggingAccessLogReceiver

      public JBossLoggingAccessLogReceiver()
  • Method Details

    • logMessage

      public void logMessage(String message)
      Specified by:
      logMessage in interface AccessLogReceiver
    • logMessage

      public void logMessage(String message, io.vertx.ext.web.RoutingContext exchange)
      Log the access-log line and populate the thread-local MDC with structured request/response fields for the duration of the logging call.
      Specified by:
      logMessage in interface AccessLogReceiver
      Parameters:
      message - the pre-formatted access log line
      exchange - the Vert.x routing context for the completed request