Class ApacheLogFormat
- java.lang.Object
-
- org.glassfish.grizzly.http.server.accesslog.ApacheLogFormat
-
- All Implemented Interfaces:
AccessLogFormat
public class ApacheLogFormat extends java.lang.Object implements AccessLogFormat
AnAccessLogFormatusing 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 " \%"%aRemote IP-address %ALocal IP-address %bSize of response in bytes, excluding HTTP headers, using " -" (a dash character) rather than a "0" (zero) when no bytes are sent%BSize of response in bytes, excluding HTTP headers %{Foobar}CThe contents of cookie " Foobar" in the request sent to the server%DThe time taken to serve the request, in microseconds %hRemote host name %{local|remote}hHost name, either " local" or "remote"%HThe request protocol %{Foobar}iThe contents of the " Foobar: ..." header in the request%mThe request method %{Foobar}oThe contents of the " Foobar: ..." header in the response%pLocal port number %{local|remote}pThe port number, either " local" or "remote"%qThe query string, prepended with a " ?" (question mark) if a query string exists, otherwise an empty string%rFirst line of request, an alias to " %m %U%q %H"%sStatus code %tThe time the request was received, in standard English format (like " [09/Feb/2014:12:00:34 +0900]")%{[format][@timezone]}tThe time the request was received. Both format and timezone are optional
- When "
format" is left unspecified, the default%tformat[yyyy/MMM/dd:HH:mm:ss Z]is used - When "
format" is specified, the given pattern must be a validSimpleDateFormatpattern. - 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).
@" character needs to be used in the format, it must be escaped as "@@"%TThe time taken to serve the request, in seconds %{...}TThe 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]"
%uThe remote user name %UThe URL path requested, not including any query string %vThe name of the server which served the request - Author:
- Pier Fumagalli, USRZ.com
-
-
Field Summary
Fields Modifier and Type Field Description static ApacheLogFormatAGENTA format compatible with Apache's user-agent format.static java.lang.StringAGENT_FORMATAStringrepresenting our version of Apache's user-agent format.static ApacheLogFormatAGENT_UTCA format compatible with Apache's user-agent format set to use the UTC time zone.static ApacheLogFormatCOMBINEDA format compatible with Apache's combined format.static java.lang.StringCOMBINED_FORMATAStringrepresenting our version of Apache's combined format.static ApacheLogFormatCOMBINED_UTCA format compatible with Apache's combined format set to use the UTC time zone.static ApacheLogFormatCOMMONA format compatible with Apache's common format.static java.lang.StringCOMMON_FORMATAStringrepresenting our version of Apache's common format.static ApacheLogFormatCOMMON_UTCA format compatible with Apache's common format set to use the UTC time zone.static ApacheLogFormatREFERERA format compatible with Apache's referer format.static java.lang.StringREFERER_FORMATAStringrepresenting our version of Apache's referer format.static ApacheLogFormatREFERER_UTCA format compatible with Apache's referer format set to use the UTC time zone.static ApacheLogFormatVHOST_COMBINEDA format compatible with Apache's combined with virtual-hosts format.static java.lang.StringVHOST_COMBINED_FORMATAStringrepresenting our version of Apache's combined with virtual-hosts format.static ApacheLogFormatVHOST_COMBINED_UTCA format compatible with Apache's combined with virtual-hosts format set to use the UTC time zone.static ApacheLogFormatVHOST_COMMONA format compatible with Apache's common with virtual-hosts format.static java.lang.StringVHOST_COMMON_FORMATAStringrepresenting our version of Apache's common with virtual-hosts format.static ApacheLogFormatVHOST_COMMON_UTCA format compatible with Apache's common with virtual-hosts format set to use the UTC time zone.
-
Constructor Summary
Constructors Constructor Description ApacheLogFormat(java.lang.String format)Create a newApacheLogFormatinstance by parsing the format from the specifiedString.ApacheLogFormat(java.util.TimeZone timeZone, java.lang.String format)Create a newApacheLogFormatinstance by parsing the format from the specifiedString.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(Response response, java.util.Date timeStamp, long responseNanos)Format the data contained in the specifiedResponseand return aStringwhich can be appended to an access log file.java.lang.StringgetFormat()Return the normalized format associated with this instance.
-
-
-
Field Detail
-
COMMON_FORMAT
public static final java.lang.String COMMON_FORMAT
AStringrepresenting our version of Apache's common format.- See Also:
- Constant Field Values
-
COMBINED_FORMAT
public static final java.lang.String COMBINED_FORMAT
AStringrepresenting our version of Apache's combined format.- See Also:
- Constant Field Values
-
VHOST_COMMON_FORMAT
public static final java.lang.String VHOST_COMMON_FORMAT
AStringrepresenting our version of Apache's common with virtual-hosts format.- See Also:
- Constant Field Values
-
VHOST_COMBINED_FORMAT
public static final java.lang.String VHOST_COMBINED_FORMAT
AStringrepresenting our version of Apache's combined with virtual-hosts format.- See Also:
- Constant Field Values
-
REFERER_FORMAT
public static final java.lang.String REFERER_FORMAT
AStringrepresenting our version of Apache's referer format.- See Also:
- Constant Field Values
-
AGENT_FORMAT
public static final java.lang.String AGENT_FORMAT
AStringrepresenting our version of Apache's user-agent format.- See Also:
- Constant Field Values
-
COMMON
public static final ApacheLogFormat COMMON
A format compatible with Apache's common format.
-
COMBINED
public static final ApacheLogFormat COMBINED
A format compatible with Apache's combined format.
-
VHOST_COMMON
public static final ApacheLogFormat VHOST_COMMON
A format compatible with Apache's common with virtual-hosts format.
-
VHOST_COMBINED
public static final ApacheLogFormat VHOST_COMBINED
A format compatible with Apache's combined with virtual-hosts format.
-
REFERER
public static final ApacheLogFormat REFERER
A format compatible with Apache's referer format.
-
AGENT
public static final ApacheLogFormat AGENT
A format compatible with Apache's user-agent format.
-
COMMON_UTC
public static final ApacheLogFormat COMMON_UTC
A format compatible with Apache's common format set to use the UTC time zone.
-
COMBINED_UTC
public static final ApacheLogFormat COMBINED_UTC
A format compatible with Apache's combined format set to use the UTC time zone.
-
VHOST_COMMON_UTC
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.
-
VHOST_COMBINED_UTC
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.
-
REFERER_UTC
public static final ApacheLogFormat REFERER_UTC
A format compatible with Apache's referer format set to use the UTC time zone.
-
AGENT_UTC
public static final ApacheLogFormat AGENT_UTC
A format compatible with Apache's user-agent format set to use the UTC time zone.
-
-
Constructor Detail
-
ApacheLogFormat
public ApacheLogFormat(java.lang.String format)
Create a newApacheLogFormatinstance by parsing the format from the specifiedString.
-
ApacheLogFormat
public ApacheLogFormat(java.util.TimeZone timeZone, java.lang.String format)Create a newApacheLogFormatinstance by parsing the format from the specifiedString.
-
-
Method Detail
-
format
public java.lang.String format(Response response, java.util.Date timeStamp, long responseNanos)
Description copied from interface:AccessLogFormatFormat the data contained in the specifiedResponseand return aStringwhich can be appended to an access log file.- Specified by:
formatin interfaceAccessLogFormat- Parameters:
response- TheResponseholding the data to format.timeStamp- TheDateat which the request was originated.responseNanos- The time, in nanoseconds, theResponsetook to complete.
-
getFormat
public java.lang.String getFormat()
Return the normalized format associated with this instance.
-
-