Class AccessLogFormatParser


  • public class AccessLogFormatParser
    extends java.lang.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
    • %{
      }i - Request header. If the argument is omitted (%i) all headers will be printed
    • %{
      }o - Response header. If the argument is omitted (%o) all headers will be printed
    • %{}C - Request cookie (COOKIE). If the argument is omitted (%C) all cookies will be printed
    • %{}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
    • %{}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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COMBINED_LOG_FORMAT
      The combined log format.
      static java.lang.String COMMON_LOG_FORMAT
      The common log format.
    • Constructor Summary

      Constructors 
      Constructor Description
      AccessLogFormatParser​(java.lang.String spec)
      Creates an AccessLogFormatParser.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AccessLog newAccessLogger()
      Returns a new AccessLogger for the specified log format.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • COMBINED_LOG_FORMAT

        public static final java.lang.String COMBINED_LOG_FORMAT
        The combined log format.
        See Also:
        Constant Field Values
      • COMMON_LOG_FORMAT

        public static final java.lang.String COMMON_LOG_FORMAT
        The common log format.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AccessLogFormatParser

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

      • newAccessLogger

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object