Package org.apache.catalina.valves

## Class ExtendedAccessLogValve

- java.lang.Object
- - org.apache.catalina.util.LifecycleBase
  - - org.apache.catalina.util.LifecycleMBeanBase
    - - org.apache.catalina.valves.ValveBase
      - - org.apache.catalina.valves.AbstractAccessLogValve
        - - org.apache.catalina.valves.AccessLogValve
          - - org.apache.catalina.valves.ExtendedAccessLogValve

All Implemented Interfaces:
  `MBeanRegistration`, `AccessLog`, `Contained`, `JmxEnabled`, `Lifecycle`, `Valve`

    public class ExtendedAccessLogValve
    extends AccessLogValve

An implementation of the W3c Extended Log File Format. See http://www.w3.org/TR/WD-logfile.html for more information about the format. The following fields are supported:

- `c-dns`: Client hostname (or ip address if `enableLookups` for the connector is false)
- `c-ip`: Client ip address
- `bytes`: bytes served
- `cs-method`: request method
- `cs-uri`: The full uri requested
- `cs-uri-query`: The query string
- `cs-uri-stem`: The uri without query string
- `date`: The date in yyyy-mm-dd format for GMT
- `s-dns`: The server dns entry
- `s-ip`: The server ip address
- `cs(XXX)`: The value of header XXX from client to server
- `sc(XXX)`: The value of header XXX from server to client
- `sc-status`: The status code
- `time`: Time the request was served
- `time-taken`: Time (in seconds) taken to serve the request
- `x-threadname`: Current request thread name (can compare later with stacktraces)
- `x-A(XXX)`: Pull XXX attribute from the servlet context
- `x-C(XXX)`: Pull the cookie(s) of the name XXX
- `x-O(XXX)`: Pull the all response header values XXX
- `x-R(XXX)`: Pull XXX attribute from the servlet request
- `x-S(XXX)`: Pull XXX attribute from the session
- `x-P(...)`: Call request.getParameter(...) and URLencode it. Helpful to capture certain POST parameters.
- For any of the x-H(...) the following method will be called from the HttpServletRequest object
- `x-H(authType)`: getAuthType
- `x-H(characterEncoding)`: getCharacterEncoding
- `x-H(contentLength)`: getContentLength
- `x-H(locale)`: getLocale
- `x-H(protocol)`: getProtocol
- `x-H(remoteUser)`: getRemoteUser
- `x-H(requestedSessionId)`: getRequestedSessionId
- `x-H(requestedSessionIdFromCookie)`: isRequestedSessionIdFromCookie
- `x-H(requestedSessionIdValid)`: isRequestedSessionIdValid
- `x-H(scheme)`: getScheme
- `x-H(secure)`: isSecure

Log rotation can be on or off. This is dictated by the `rotatable` property.

For UNIX users, another field called `checkExists` is also available. If set to true, the log file's existence will be checked before each logging. This way an external log rotator can move the file somewhere and Tomcat will start with a new file.

For JMX junkies, a public method called `rotate` has been made available to allow you to tell this instance to move the existing log file to somewhere else and start writing a new log file.

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.

For extended attributes coming from a getAttribute() call, it is you responsibility to ensure there are no newline or control characters.

Author:
  Peter Rossbach

### Nested Class Summary

Nested Classes
`protected static class` `ExtendedAccessLogValve.CookieElement`
`protected static class` `ExtendedAccessLogValve.DateElement`
`protected static class` `ExtendedAccessLogValve.PatternTokenizer`
`protected static class` `ExtendedAccessLogValve.RequestAttributeElement`
`protected static class` `ExtendedAccessLogValve.RequestHeaderElement`
`protected static class` `ExtendedAccessLogValve.RequestParameterElement`
`protected static class` `ExtendedAccessLogValve.ResponseAllHeaderElement` write a specific response header - x-O(xxx)
`protected static class` `ExtendedAccessLogValve.ResponseHeaderElement`
`protected static class` `ExtendedAccessLogValve.ServletContextElement`
`protected static class` `ExtendedAccessLogValve.SessionAttributeElement`
`protected static class` `ExtendedAccessLogValve.TimeElement`

### Nested classes/interfaces inherited from class org.apache.catalina.valves.AbstractAccessLogValve

`AbstractAccessLogValve.AccessLogElement, AbstractAccessLogValve.ByteSentElement, AbstractAccessLogValve.CachedElement, AbstractAccessLogValve.ConnectionStatusElement, AbstractAccessLogValve.DateAndTimeElement, AbstractAccessLogValve.DateFormatCache, AbstractAccessLogValve.ElapsedTimeElement, AbstractAccessLogValve.FirstByteTimeElement, AbstractAccessLogValve.HeaderElement, AbstractAccessLogValve.HostElement, AbstractAccessLogValve.HttpStatusCodeElement, AbstractAccessLogValve.LocalAddrElement, AbstractAccessLogValve.LocalServerNameElement, AbstractAccessLogValve.LogicalUserNameElement, AbstractAccessLogValve.MethodElement, AbstractAccessLogValve.PortElement, AbstractAccessLogValve.ProtocolElement, AbstractAccessLogValve.QueryElement, AbstractAccessLogValve.RemoteAddrElement, AbstractAccessLogValve.RequestElement, AbstractAccessLogValve.RequestURIElement, AbstractAccessLogValve.SessionIdElement, AbstractAccessLogValve.StringElement, AbstractAccessLogValve.ThreadNameElement, AbstractAccessLogValve.UserElement`

### Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

`Lifecycle.SingleUse`

### Field Summary

### Fields inherited from class org.apache.catalina.valves.AccessLogValve

`currentLogFile, encoding, fileDateFormat, fileDateFormatter, prefix, renameOnRotate, rotatable, suffix, writer`

### Fields inherited from class org.apache.catalina.valves.AbstractAccessLogValve

`cachedElements, condition, conditionIf, enabled, locale, localeName, logElements, pattern, requestAttributesEnabled`

### Fields inherited from class org.apache.catalina.valves.ValveBase

`asyncSupported, container, containerLog, next, sm`

### Fields inherited from interface org.apache.catalina.AccessLog

`PROTOCOL_ATTRIBUTE, REMOTE_ADDR_ATTRIBUTE, REMOTE_HOST_ATTRIBUTE, SERVER_NAME_ATTRIBUTE, SERVER_PORT_ATTRIBUTE`

### Fields inherited from interface org.apache.catalina.Lifecycle

`AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

### Constructor Summary

Constructors
`ExtendedAccessLogValve()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected AbstractAccessLogValve.AccessLogElement[]` `createLogElements()` Parse pattern string and create the array of AccessLogElement.
`protected AbstractAccessLogValve.AccessLogElement` `getClientToServerElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)`
`protected AbstractAccessLogValve.AccessLogElement` `getLogElement​(String token, ExtendedAccessLogValve.PatternTokenizer tokenizer)`
`protected AbstractAccessLogValve.AccessLogElement` `getProxyElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)`
`protected AbstractAccessLogValve.AccessLogElement` `getServerToClientElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)`
`protected AbstractAccessLogValve.AccessLogElement` `getServletRequestElement​(String parameter)`
`protected AbstractAccessLogValve.AccessLogElement` `getXParameterElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)`
`protected void` `open()` Open the new log file for the date specified by `dateStamp`.

### Methods inherited from class org.apache.catalina.valves.AccessLogValve

`backgroundProcess, getDirectory, getEncoding, getFileDateFormat, getMaxDays, getPrefix, getSuffix, isBuffered, isCheckExists, isRenameOnRotate, isRotatable, log, rotate, rotate, setBuffered, setCheckExists, setDirectory, setEncoding, setFileDateFormat, setMaxDays, setPrefix, setRenameOnRotate, setRotatable, setSuffix, startInternal, stopInternal`

### Methods inherited from class org.apache.catalina.valves.AbstractAccessLogValve

`createAccessLogElement, createAccessLogElement, escapeAndAppend, findLocale, getCondition, getConditionIf, getConditionUnless, getEnabled, getIpv6Canonical, getLocale, getMaxLogMessageBufferSize, getPattern, getRequestAttributesEnabled, invoke, log, setCondition, setConditionIf, setConditionUnless, setEnabled, setIpv6Canonical, setLocale, setMaxLogMessageBufferSize, setPattern, setRequestAttributesEnabled`

### Methods inherited from class org.apache.catalina.valves.ValveBase

`getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, toString`

### Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase

`destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister`

### Methods inherited from class org.apache.catalina.util.LifecycleBase

`addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### ExtendedAccessLogValve

    public ExtendedAccessLogValve()

### Method Detail

#### open

    protected void open()

Open the new log file for the date specified by `dateStamp`.

Overrides:
  `open` in class `AccessLogValve`

#### createLogElements

    protected AbstractAccessLogValve.AccessLogElement[] createLogElements()

Description copied from class: `AbstractAccessLogValve`
Parse pattern string and create the array of AccessLogElement.

Overrides:
  `createLogElements` in class `AbstractAccessLogValve`
Returns:
  the log elements array

#### getLogElement

    protected AbstractAccessLogValve.AccessLogElement getLogElement​(String token,
                                                                    ExtendedAccessLogValve.PatternTokenizer tokenizer)
                                                             throws IOException

Throws:
  `IOException`

#### getClientToServerElement

    protected AbstractAccessLogValve.AccessLogElement getClientToServerElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)
                                                                        throws IOException

Throws:
  `IOException`

#### getServerToClientElement

    protected AbstractAccessLogValve.AccessLogElement getServerToClientElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)
                                                                        throws IOException

Throws:
  `IOException`

#### getProxyElement

    protected AbstractAccessLogValve.AccessLogElement getProxyElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)
                                                               throws IOException

Throws:
  `IOException`

#### getXParameterElement

    protected AbstractAccessLogValve.AccessLogElement getXParameterElement​(ExtendedAccessLogValve.PatternTokenizer tokenizer)
                                                                    throws IOException

Throws:
  `IOException`

#### getServletRequestElement

    protected AbstractAccessLogValve.AccessLogElement getServletRequestElement​(String parameter)