Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http.server.accesslog

public Class ApacheLogFormat

extends Object
implements AccessLogFormat
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.http.server.accesslog.AccessLogFormat
Static Imports
java.util.logging.Level.WARNING

An AccessLogFormat using a standard vaguely similar and heavily influenced by Apache's own custom access log formats.

As with Apache, the format string specified at construction should be composed of these tokens:

%% The literal percent sign (can also be escaped with back-slash, like "\%"
%a Remote IP-address
%A Local IP-address
%b Size of response in bytes, excluding HTTP headers, using "-" (a dash character) rather than a "0" (zero) when no bytes are sent
%B Size of response in bytes, excluding HTTP headers
%{Foobar}C The contents of cookie "Foobar" in the request sent to the server
%D The time taken to serve the request, in microseconds
%h Remote host name
%{local|remote}h Host name, either "local" or "remote"
%H The request protocol
%{Foobar}i The contents of the "Foobar: ..." header in the request
%m The request method
%{Foobar}o The contents of the "Foobar: ..." header in the response
%p Local port number
%{local|remote}p The port number, either "local" or "remote"
%q The query string, prepended with a "?" (question mark) if a query string exists, otherwise an empty string
%r First line of request, an alias to "%m %U%q %H"
%s Status code
%t The time the request was received, in standard English format (like "[09/Feb/2014:12:00:34 +0900]")
%{[format][@timezone]}t The time the request was received. Both format and timezone are optional
  • When "format" is left unspecified, the default %t format [yyyy/MMM/dd:HH:mm:ss Z] is used
  • When "format" is specified, the given pattern must be a valid DateTimeFormatter pattern.
  • When "@timezone" is left unspecified, the default time zone is used.
  • When "@timezone" is specified, the time zone will be looked up by time zone identifier (note that this will default to GMT if the specified identifier was not recognized).
When the "@" character needs to be used in the format, it must be escaped as "@@"
%T The time taken to serve the request, in seconds
%{...}T The time taken to serve the request. The parameter can be a time unit like:
  • "n", "nano[s]", "nanosec[s]", "nanosecond[s]"
  • "micro[s]", "microsec[s]", "microsecond[s]"
  • "m", "milli[s]", "millisec[s]", "millisecond[s]"
  • "s", "sec[s]", "second[s]"
%u The remote user name
%U The URL path requested, not including any query string
%v The name of the server which served the request
Authors
Pier Fumagalli, USRZ.com

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
private abstract static class
private abstract static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
public static final ApacheLogFormat
AGENT

A format compatible with Apache's user-agent format.

public static final String
AGENT_FORMAT

A String representing our version of Apache's user-agent format.

public static final ApacheLogFormat
AGENT_UTC

A format compatible with Apache's user-agent format set to use the UTC time zone.

public static final ApacheLogFormat
COMBINED

A format compatible with Apache's combined format.

public static final String
COMBINED_FORMAT

A String representing our version of Apache's combined format.

public static final ApacheLogFormat
COMBINED_UTC

A format compatible with Apache's combined format set to use the UTC time zone.

public static final ApacheLogFormat
COMMON

A format compatible with Apache's common format.

public static final String
COMMON_FORMAT

A String representing our version of Apache's common format.

public static final ApacheLogFormat
COMMON_UTC

A format compatible with Apache's common format set to use the UTC time zone.

private final List<ApacheLogFormat.Field>
private static final Logger
public static final ApacheLogFormat
REFERER

A format compatible with Apache's referer format.

public static final String
REFERER_FORMAT

A String representing our version of Apache's referer format.

public static final ApacheLogFormat
REFERER_UTC

A format compatible with Apache's referer format set to use the UTC time zone.

private final ZoneId
private static final ZoneId
public static final ApacheLogFormat
VHOST_COMBINED

A format compatible with Apache's combined with virtual-hosts format.

public static final String
VHOST_COMBINED_FORMAT

A String representing our version of Apache's combined with virtual-hosts format.

public static final ApacheLogFormat
VHOST_COMBINED_UTC

A format compatible with Apache's combined with virtual-hosts format set to use the UTC time zone.

public static final ApacheLogFormat
VHOST_COMMON

A format compatible with Apache's common with virtual-hosts format.

public static final String
VHOST_COMMON_FORMAT

A String representing our version of Apache's common with virtual-hosts format.

public static final ApacheLogFormat
VHOST_COMMON_UTC

A format compatible with Apache's common with virtual-hosts format set to use the UTC time zone.

Constructor Summary

AccessConstructor and Description
public
ApacheLogFormat(String format)

Create a new ApacheLogFormat instance by parsing the format from the specified String.

public
ApacheLogFormat(TimeZone timeZone, String format)

Create a new ApacheLogFormat instance by parsing the format from the specified String.

public
ApacheLogFormat(final ZoneId timeZone, final String format)

Create a new ApacheLogFormat instance by parsing the format from the specified String.

Method Summary

Modifier and TypeMethod and Description
private void
addLiteral(char c)

public String
format(Response response, Date timeStamp, long responseNanos)

Implements org.glassfish.grizzly.http.server.accesslog.AccessLogFormat.format.

Format the data contained in the specified Response and return a String which can be appended to an access log file.

public String
getFormat()

Return the normalized format associated with this instance.

private void
parse(String format)

private int
parseEscape(String format, int position)

private int
parseFormat(String format, String parameter, int position)

private boolean
parseLocal(String parameter, boolean defaultValue, char field, String format, int position)

private int
parseParameter(String format, int position)

pack-priv String
unsafeFormat(Response response, Date timeStamp, long responseNanos)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait