Enum Class LogFormat

java.lang.Object
java.lang.Enum<LogFormat>
org.microproxy.extras.LogFormat
All Implemented Interfaces:
Serializable, Comparable<LogFormat>, Constable

public enum LogFormat extends Enum<LogFormat>
Named access-log formats for ActivityLogger, each a preset of AccessLogFormat: an Envoy-compatible format string (or JSON dictionary) shown on each constant. Custom formats come from envoy(String) and envoyJson(Map).

The presets use a few operators of MicroProxy's own: %MP_URL% (the absolute URL), %MP_USER% (the authenticated user), %MP_RESPONSE_SOURCE%, %MP_UPSTREAM_STATUS% and %MP_TIMING(phase)%.

  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    NCSA Common Log Format: host ident authuser [date] "request" status bytes, as %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% - %MP_USER% [%START_TIME(%d/%b/%Y:%H:%M:%S %z)%] "%REQ(:METHOD)% %MP_URL% %PROTOCOL%" %RESPONSE_CODE% %BYTES_SENT%.
    RFC 4180 comma-separated values, every field quoted: time, client, method, URL, status, bytes, duration, user agent.
    NCSA Combined (extended) format: CLF plus "%REQ(REFERER)%" "%REQ(USER-AGENT)%".
    Envoy's default format (AccessLogFormat.ENVOY_DEFAULT).
    HAProxy-style HTTP log: client [date] "request" status bytes duration, as %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% [%START_TIME(%d/%b/%Y:%H:%M:%S.%3f)%] "%REQ(:METHOD)% %MP_URL% %PROTOCOL%" %RESPONSE_CODE% %BYTES_SENT% %DURATION%.
    One JSON object per line: timestamp, client_ip, user, method, uri, protocol, status, bytes, duration (milliseconds) and user_agent.
    JSON plus where the response came from and how it went: source (ResponseSource), upstream_status (the server's status, or null), ttfb_ms, total_ms, dns_ms, connect_ms and tls_ms (milliseconds, or null for phases that did not happen), response_flags, response_code_details and flow (the kind of exchange or flow).
    Labeled tab-separated values: time, host, user, method, uri, status, size, duration, ua.
    Squid native: time elapsed client code/status bytes method URL user hierarchy/peer type, as %START_TIME(%s.%3f)% %DURATION% %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% TCP_MISS/%RESPONSE_CODE% %BYTES_SENT% %REQ(:METHOD)% %MP_URL% %MP_USER% DIRECT/%UPSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% %RESP(CONTENT-TYPE)%; spaces in values become _, so each value stays one column.
    W3C extended: date time c-ip cs-method cs-uri sc-status sc-bytes "cs(User-Agent)", as %START_TIME(%Y-%m-%d %H:%M:%S)% %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% %REQ(:METHOD)% %MP_URL% %RESPONSE_CODE% %BYTES_SENT% "%REQ(USER-AGENT)%".
  • Method Summary

    Modifier and Type
    Method
    Description
    envoy(String format)
    A custom format: an Envoy format string (see AccessLogFormat.envoy(java.lang.String)).
    envoyJson(Map<String,?> dictionary)
    A custom JSON format: keys and the format strings of their values (see AccessLogFormat.envoyJson(Map)).
    Returns this preset as an AccessLogFormat.
    parse(String presetOrFormat)
    A preset by name (clf, envoy, ..., ignoring case), or else an Envoy format string: what the command line's --access-log-format takes.
    static LogFormat
    Returns the enum constant of this class with the specified name.
    static LogFormat[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • CLF

      public static final LogFormat CLF
      NCSA Common Log Format: host ident authuser [date] "request" status bytes, as %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% - %MP_USER% [%START_TIME(%d/%b/%Y:%H:%M:%S %z)%] "%REQ(:METHOD)% %MP_URL% %PROTOCOL%" %RESPONSE_CODE% %BYTES_SENT%.
    • ELF

      public static final LogFormat ELF
      NCSA Combined (extended) format: CLF plus "%REQ(REFERER)%" "%REQ(USER-AGENT)%".
    • JSON

      public static final LogFormat JSON
      One JSON object per line: timestamp, client_ip, user, method, uri, protocol, status, bytes, duration (milliseconds) and user_agent.
    • SQUID

      public static final LogFormat SQUID
      Squid native: time elapsed client code/status bytes method URL user hierarchy/peer type, as %START_TIME(%s.%3f)% %DURATION% %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% TCP_MISS/%RESPONSE_CODE% %BYTES_SENT% %REQ(:METHOD)% %MP_URL% %MP_USER% DIRECT/%UPSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% %RESP(CONTENT-TYPE)%; spaces in values become _, so each value stays one column.
    • W3C

      public static final LogFormat W3C
      W3C extended: date time c-ip cs-method cs-uri sc-status sc-bytes "cs(User-Agent)", as %START_TIME(%Y-%m-%d %H:%M:%S)% %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% %REQ(:METHOD)% %MP_URL% %RESPONSE_CODE% %BYTES_SENT% "%REQ(USER-AGENT)%".
    • LTSV

      public static final LogFormat LTSV
      Labeled tab-separated values: time, host, user, method, uri, status, size, duration, ua.
    • CSV

      public static final LogFormat CSV
      RFC 4180 comma-separated values, every field quoted: time, client, method, URL, status, bytes, duration, user agent.
    • HAPROXY

      public static final LogFormat HAPROXY
      HAProxy-style HTTP log: client [date] "request" status bytes duration, as %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT% [%START_TIME(%d/%b/%Y:%H:%M:%S.%3f)%] "%REQ(:METHOD)% %MP_URL% %PROTOCOL%" %RESPONSE_CODE% %BYTES_SENT% %DURATION%.
    • JSON_EXTENDED

      public static final LogFormat JSON_EXTENDED
      JSON plus where the response came from and how it went: source (ResponseSource), upstream_status (the server's status, or null), ttfb_ms, total_ms, dns_ms, connect_ms and tls_ms (milliseconds, or null for phases that did not happen), response_flags, response_code_details and flow (the kind of exchange or flow).
    • ENVOY

      public static final LogFormat ENVOY
      Envoy's default format (AccessLogFormat.ENVOY_DEFAULT).
  • Method Details

    • values

      public static LogFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static LogFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • formatter

      public AccessLogFormat formatter()
      Returns this preset as an AccessLogFormat.
      Returns:
      this preset as an AccessLogFormat
    • envoy

      public static AccessLogFormat envoy(String format)
      A custom format: an Envoy format string (see AccessLogFormat.envoy(java.lang.String)).
      Parameters:
      format - the format string
      Returns:
      the format
    • envoyJson

      public static AccessLogFormat envoyJson(Map<String,?> dictionary)
      A custom JSON format: keys and the format strings of their values (see AccessLogFormat.envoyJson(Map)).
      Parameters:
      dictionary - the keys and their format strings
      Returns:
      the format
    • parse

      public static AccessLogFormat parse(String presetOrFormat)
      A preset by name (clf, envoy, ..., ignoring case), or else an Envoy format string: what the command line's --access-log-format takes.
      Parameters:
      presetOrFormat - a preset name or a format string
      Returns:
      the format
      Throws:
      IllegalArgumentException - if it is neither a preset nor a format string with an operator