Class AccessLogFormatParser

java.lang.Object
io.micronaut.http.server.netty.handler.accesslog.element.AccessLogFormatParser

public class AccessLogFormatParser extends Object
The access log format parser.

The syntax is based on Apache httpd log format. Here are the supported directives:

  • %a - Remote IP address
  • %A - Local IP address
  • %b - Bytes sent, excluding HTTP headers, or '-' if no bytes were sent
  • %B - Bytes sent, excluding HTTP headers
  • %h - Remote host name
  • %H - Request protocol
  • %{<header>}i - Request header. If the argument is omitted (%i) all headers will be printed
  • %{<header>}o - Response header. If the argument is omitted (%o) all headers will be printed
  • %{<cookie>}C - Request cookie (COOKIE). If the argument is omitted (%C) all cookies will be printed
  • %{<cookie>}c - Response cookie (SET_COOKIE). If the argument is omitted (%c) all cookies will be printed
  • %l - Remote logical username from identd (always returns '-')
  • %m - Request method
  • %p - Local port
  • %q - Query string (excluding the '?' character)
  • %r - First line of the request
  • %s - HTTP status code of the response
  • %{<format>}t - Date and time. If the argument is omitted the Common Log Format format is used ("'['dd/MMM/yyyy:HH:mm:ss Z']'"). If the format starts with begin: (default) the time is taken at the beginning of the request processing. If it starts with end: it is the time when the log entry gets written, close to the end of the request processing. The format should follow the DateTimeFormatter syntax.
  • %u - Remote user that was authenticated. Not implemented. Prints '-'.
  • %U - Requested URI
  • %v - Local server name
  • %D - Time taken to process the request, in millis
  • %T - Time taken to process the request, in seconds

In addition, the following aliases for commonly utilized patterns:

  • common - %h %l %u %t "%r" %s %b Common Log Format (CLF)
  • combined - %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" Combined Log Format
Since:
2.0
Author:
croudet
  • Field Details

  • Constructor Details

    • AccessLogFormatParser

      public AccessLogFormatParser(String spec)
      Creates an AccessLogFormatParser.
      Parameters:
      spec - The log format. When null the Common Log Format is used.
  • Method Details

    • newAccessLogger

      public AccessLog newAccessLogger()
      Returns a new AccessLogger for the specified log format.
      Returns:
      A AccessLogger.
    • toString

      public String toString()
      Overrides:
      toString in class Object