Implementation of the Valve interface that generates a web server access log with the detailed line contents matching a configurable pattern. The syntax of the available patterns is similar to that supported by the Apache mod_log_config
module. As an additional feature, automatic rollover of log files when the date changes is also supported.
Patterns for the logged message may include constant text or any of the following replacement strings, for which the corresponding information from the specified Response is substituted:
- %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
- %l - Remote logical username from identd (always returns '-')
- %m - Request method
- %p - Local port
- %q - Query string (prepended with a '?' if it exists, otherwise an empty string
- %r - First line of the request
- %s - HTTP status code of the response
- %S - User session ID
- %t - Date and time, in Common Log Format format
- %u - Remote user that was authenticated
- %U - Requested URL path
- %v - Local server name
- %D - Time taken to process the request, in millis
- %T - Time taken to process the request, in seconds
- %I - current Request thread name (can compare later with stacktraces)
In addition, the caller can specify one of the following aliases for commonly utilized patterns:
- common -
%h %l %u %t "%r" %s %b
- combined -
%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"
There is also support to write information from the cookie, incoming header, the Session or something else in the ServletRequest.
It is modeled after the apache syntax:
%{xxx}i
for incoming headers %{xxx}o
for outgoing response headers %{xxx}c
for a specific cookie %{xxx}r
xxx is an attribute in the ServletRequest %{xxx}s
xxx is an attribute in the HttpSession
Conditional logging is also supported. This can be done with the condition
property. If the value returned from ServletRequest.getAttribute(condition) yields a non-null value. The logging will be skipped.
@author Craig R. McClanahan
@author Jason Brittain
@author Remy Maucherat
@author Takayuki Kaneko
@author Peter Rossbach
@version $Revision: 779 $ $Date: 2008-09-17 08:26:33 -0400 (Wed, 17 Sep 2008) $