JsonAccessLogValve (Apache Tomcat 8.5.96 API Documentation)

Package org.apache.catalina.valves

## Class JsonAccessLogValve

- 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.JsonAccessLogValve

- All Implemented Interfaces:
    `javax.management.MBeanRegistration`, `AccessLog`, `Contained`, `JmxEnabled`, `Lifecycle`, `Valve`

      public class JsonAccessLogValve
      extends AccessLogValve

  Access log valve derivative that rewrites entries as JSON. Important note: the attribute names are not final Patterns are mapped to attributes as followed:
  - a: remoteAddr
  - A: localAddr
  - b: size (byteSent: size)
  - B: byteSentNC
  - D: elapsedTime
  - F: firstByteTime
  - h: host
  - H: protocol
  - l: logicalUserName
  - m: method
  - p: port
  - q: query
  - r: request
  - s: statusCode
  - S: sessionId
  - t: time (dateTime: time)
  - T: elapsedTimeS
  - u: user
  - U: path (requestURI: path)
  - v: localServerName
  - I: threadName
  - X: connectionStatus
  - %{xxx}a: remoteAddress-xxx
  - %{xxx}p: port-xxx
  - %{xxx}t: time-xxx
  - %{xxx}c: cookies
  - %{xxx}i: requestHeaders
  - %{xxx}o: responseHeaders
  - %{xxx}r: requestAttributes
  - %{xxx}s: sessionAttributes
  The attribute list is based on https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/parser_apache2.rb#L72

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `protected static class` | `JsonAccessLogValve.CharElement` | write any char

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

      `AbstractAccessLogValve.AccessLogElement, AbstractAccessLogValve.ByteSentElement, AbstractAccessLogValve.CachedElement, AbstractAccessLogValve.ConnectionStatusElement, AbstractAccessLogValve.CookieElement, 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.RequestAttributeElement, AbstractAccessLogValve.RequestElement, AbstractAccessLogValve.RequestURIElement, AbstractAccessLogValve.ResponseHeaderElement, AbstractAccessLogValve.SessionAttributeElement, 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 class org.apache.catalina.util.LifecycleMBeanBase

      `mserver`

    - ### 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
    Constructor | Description
    --- | ---
    `JsonAccessLogValve()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected AbstractAccessLogValve.AccessLogElement` | `createAccessLogElement​(char pattern)` | Create an AccessLogElement implementation.
    `protected AbstractAccessLogValve.AccessLogElement` | `createAccessLogElement​(java.lang.String name, char pattern)` | Create an AccessLogElement implementation which needs an element name.
    `protected AbstractAccessLogValve.AccessLogElement[]` | `createLogElements()` | Parse pattern string and create the array of AccessLogElement.

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

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

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

      `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`

    - ### 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

    - #### JsonAccessLogValve

          public JsonAccessLogValve()

  - ### Method Detail

    - #### 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

    - #### createAccessLogElement

          protected AbstractAccessLogValve.AccessLogElement createAccessLogElement​(java.lang.String name,
                                                                                   char pattern)

      Description copied from class: `AbstractAccessLogValve`
      Create an AccessLogElement implementation which needs an element name.
      Overrides:
        `createAccessLogElement` in class `AbstractAccessLogValve`
      Parameters:
        `name` - Header name
        `pattern` - char in the log pattern
      Returns:
        the log element

    - #### createAccessLogElement

          protected AbstractAccessLogValve.AccessLogElement createAccessLogElement​(char pattern)

      Description copied from class: `AbstractAccessLogValve`
      Create an AccessLogElement implementation.
      Overrides:
        `createAccessLogElement` in class `AbstractAccessLogValve`
      Parameters:
        `pattern` - char in the log pattern
      Returns:
        the log element