- %a - Remote IP address
- %A - Local IP address
- %b - Bytes sent, excluding HTTP headers, or '-' if zero
- %B - Bytes sent, excluding HTTP headers
- %h - Remote host name (or IP address if
resolveHosts
is false) - %H - Request protocol
- %l - Remote logical username from identd (always returns '-')
- %m - Request method (GET, POST, etc.)
- %p - Local port on which this request was received
- %q - Query string (prepended with a '?' if it exists)
- %r - First line of the request (method and request URI)
- %s - HTTP status code of the response
- %S - User session ID
- %t - Date and time, in Common Log Format
- %u - Remote user that was authenticated (if any), else '-'
- %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)
http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html
[Date and time] [Remote IP] [Bytes sent] [Request method] [HTTP status code of the response] [Time taken in millis] [User session ID] [Current request thread name]
%t [%a] [%b] [%m] [%s] [%D] [%S] [%I] [%H://%v%U%q]
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%t [%a] [%b] [%m] [%s] [%D] [%S] [%I] [%H://%v%U%q]" />
proxy:
pattern: %{X-Forwarded-For}
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%{X-Forwarded-For} i %t [%a] [%b] [%m] [%s] [%D] [%S] [%I] [%H://%v%U%q]" />
http://www.docjar.org/docs/api/org/apache/catalina/valves/AccessLogValve.html
org.apache.catalina.valves
public class: AccessLogValve [javadoc | source]
java.lang.Objectorg.apache.catalina.valves.ValveBase
org.apache.catalina.valves.AccessLogValve
All Implemented Interfaces:
Lifecycle, Valve, MBeanRegistration, Contained
Direct Known Subclasses:
FastCommonAccessLogValve, ExtendedAccessLogValve
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 Apachemod_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: 832123 $ $Date: 2009-11-02 22:57:21 +0100 (Mon, 02 Nov 2009) $
- author:
Nested Class Summary: | ||
---|---|---|
protected interface | AccessLogValve.AccessLogElement | AccessLogElement writes the partial message into the buffer. |
protected class | AccessLogValve.ThreadNameElement | write thread name - %I |
protected static class | AccessLogValve.LocalAddrElement | write local IP address - %A |
protected class | AccessLogValve.RemoteAddrElement | write remote IP address - %a |
protected class | AccessLogValve.HostElement | write remote host name - %h |
protected class | AccessLogValve.LogicalUserNameElement | write remote logical username from identd (always returns '-') - %l |
protected class | AccessLogValve.ProtocolElement | write request protocol - %H |
protected class | AccessLogValve.UserElement | write remote user that was authenticated (if any), else '-' - %u |
protected class | AccessLogValve.DateAndTimeElement | write date and time, in Common Log Format - %t |
protected class | AccessLogValve.RequestElement | write first line of the request (method and request URI) - %r |
protected class | AccessLogValve.HttpStatusCodeElement | write HTTP status code of the response - %s |
protected class | AccessLogValve.LocalPortElement | write local port on which this request was received - %p |
protected class | AccessLogValve.ByteSentElement | write bytes sent, excluding HTTP headers - %b, %B |
protected class | AccessLogValve.MethodElement | write request method (GET, POST, etc.) - %m |
protected class | AccessLogValve.ElapsedTimeElement | write time taken to process the request - %D, %T |
protected class | AccessLogValve.QueryElement | write Query string (prepended with a '?' if it exists) - %q |
protected class | AccessLogValve.SessionIdElement | write user session ID - %S |
protected class | AccessLogValve.RequestURIElement | write requested URL path - %U |
protected class | AccessLogValve.LocalServerNameElement | write local server name - %v |
protected class | AccessLogValve.StringElement | write any string |
protected class | AccessLogValve.HeaderElement | write incoming headers - %{xxx}i |
protected class | AccessLogValve.CookieElement | write a specific cookie - %{xxx}c |
protected class | AccessLogValve.ResponseHeaderElement | write a specific response header - %{xxx}o |
protected class | AccessLogValve.RequestAttributeElement | write an attribute in the ServletRequest - %{xxx}r |
protected class | AccessLogValve.SessionAttributeElement | write an attribute in the HttpSession - %{xxx}s |
Field Summary | ||
---|---|---|
protected static final String | info | The descriptive information about this implementation. |
protected LifecycleSupport | lifecycle | The lifecycle event support for this component. |
protected static final String[] | months | The set of month abbreviations for log messages. |
protected boolean | enabled | enabled this component |
protected String | pattern | The pattern used to format our access log lines. |
protected String | prefix | The prefix that is added to log file filenames. |
protected boolean | rotatable | Should we rotate our log file? Default is true (like old behavior) |
protected StringManager | sm | The string manager for this package. |
protected boolean | started | Has this component been started yet? |
protected String | suffix | The suffix that is added to log file filenames. |
protected PrintWriter | writer | The PrintWriter to which we are currently logging, if any. |
protected SimpleDateFormat | fileDateFormatter | A date formatter to format a Date into a date in the format "yyyy-MM-dd". |
protected File | currentLogFile | The current log file we are writing to. Helpful when checkExists is true. |
protected String | condition | Are we doing conditional logging. default false. |
protected String | fileDateFormat | Date format to place in log file name. Use at your own risk! |
protected AccessLogElement[] | logElements | Array of AccessLogElement, they will be used to make log message. |
Fields inherited from org.apache.catalina.valves.ValveBase: |
---|
container, containerLog, info, next, sm, domain, oname, mserver, controller |
Method from org.apache.catalina.valves.AccessLogValve Summary: |
---|
addLifecycleListener, backgroundProcess, createLogElements, findLifecycleListeners, getCondition, getDirectory, getEnabled, getFileDateFormat, getInfo, getPattern, getPrefix, getSuffix, invoke, isBuffered, isCheckExists, isResolveHosts, isRotatable, log, open, removeLifecycleListener, rotate, setBuffered, setCheckExists, setCondition, setDirectory, setEnabled, setFileDateFormat, setPattern, setPrefix, setResolveHosts, setRotatable, setSuffix, start, stop |
Methods from org.apache.catalina.valves.ValveBase: |
---|
backgroundProcess, createObjectName, event, getContainer, getContainerName, getController, getDomain, getInfo, getNext, getObjectName, getParentName, invoke, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName, toString |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.catalina.valves.AccessLogValve Detail: |
---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|