Package org.microproxy.extras
Enum Class LogFormat
- All Implemented Interfaces:
Serializable,Comparable<LogFormat>,Constable
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 ConstantsEnum ConstantDescriptionNCSA 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) anduser_agent.JSONplus where the response came from and how it went:source(ResponseSource),upstream_status(the server's status, ornull),ttfb_ms,total_ms,dns_ms,connect_msandtls_ms(milliseconds, ornullfor phases that did not happen),response_flags,response_code_detailsandflow(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 TypeMethodDescriptionstatic AccessLogFormatA custom format: an Envoy format string (seeAccessLogFormat.envoy(java.lang.String)).static AccessLogFormatA custom JSON format: keys and the format strings of their values (seeAccessLogFormat.envoyJson(Map)).Returns this preset as anAccessLogFormat.static AccessLogFormatA preset by name (clf,envoy, ..., ignoring case), or else an Envoy format string: what the command line's--access-log-formattakes.static LogFormatReturns the enum constant of this class with the specified name.static LogFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
NCSA Combined (extended) format: CLF plus"%REQ(REFERER)%" "%REQ(USER-AGENT)%". -
JSON
One JSON object per line:timestamp,client_ip,user,method,uri,protocol,status,bytes,duration(milliseconds) anduser_agent. -
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
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
Labeled tab-separated values:time,host,user,method,uri,status,size,duration,ua. -
CSV
RFC 4180 comma-separated values, every field quoted: time, client, method, URL, status, bytes, duration, user agent. -
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
JSONplus where the response came from and how it went:source(ResponseSource),upstream_status(the server's status, ornull),ttfb_ms,total_ms,dns_ms,connect_msandtls_ms(milliseconds, ornullfor phases that did not happen),response_flags,response_code_detailsandflow(the kind of exchange or flow). -
ENVOY
Envoy's default format (AccessLogFormat.ENVOY_DEFAULT).
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
formatter
Returns this preset as anAccessLogFormat.- Returns:
- this preset as an
AccessLogFormat
-
envoy
A custom format: an Envoy format string (seeAccessLogFormat.envoy(java.lang.String)).- Parameters:
format- the format string- Returns:
- the format
-
envoyJson
A custom JSON format: keys and the format strings of their values (seeAccessLogFormat.envoyJson(Map)).- Parameters:
dictionary- the keys and their format strings- Returns:
- the format
-
parse
A preset by name (clf,envoy, ..., ignoring case), or else an Envoy format string: what the command line's--access-log-formattakes.- 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
-