Top Description Inners Fields Constructors Methods
org.apache.catalina.valves

public Class JsonAccessLogValve

extends AccessLogValve
Class Inheritance
Imports
java.io.CharArrayWriter, java.util.ArrayList, .Arrays, .Collections, .Date, .HashMap, .List, .ListIterator, .Map, org.apache.catalina.connector.Request, .Response, org.apache.tomcat.util.json.JSONFilter

Access log valve derivative that rewrites entries as JSON. Important note: the attribute names are not final Patterns are mapped to attributes as followed: The attribute list is based on https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/parser_apache2.rb#L72

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
private static class

Field Summary

Modifier and TypeField and Description
private static final Map<Character, String>
private static final Map<Character, String>
Inherited from org.apache.catalina.valves.AccessLogValve:
currentLogFileencodingfileDateFormatfileDateFormatterprefixrenameOnRotaterotatablesuffixwriter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private boolean
protected AbstractAccessLogValve.AccessLogElement
createAccessLogElement(String
Header name
name
,
char
char in the log pattern
pattern
)

Overrides org.apache.catalina.valves.AbstractAccessLogValve.createAccessLogElement.

Create an AccessLogElement implementation which needs an element name.

protected AbstractAccessLogValve.AccessLogElement
createAccessLogElement(char
char in the log pattern
pattern
)

Overrides org.apache.catalina.valves.AbstractAccessLogValve.createAccessLogElement.

Create an AccessLogElement implementation.

protected AbstractAccessLogValve.AccessLogElement[]
createLogElements()

Overrides org.apache.catalina.valves.AbstractAccessLogValve.createLogElements.

Parse pattern string and create the array of AccessLogElement.

Inherited from org.apache.catalina.valves.AccessLogValve:
backgroundProcessgetDirectorygetEncodinggetFileDateFormatgetMaxDaysgetPrefixgetSuffixisBufferedisCheckExistsisRenameOnRotateisRotatablelogopenrotaterotatesetBufferedsetCheckExistssetDirectorysetEncodingsetFileDateFormatsetMaxDayssetPrefixsetRenameOnRotatesetRotatablesetSuffixstartInternalstopInternal

Field Detail

PATTERNSback to summary
private static final Map<Character, String> PATTERNS
SUB_OBJECT_PATTERNSback to summary
private static final Map<Character, String> SUB_OBJECT_PATTERNS

Constructor Detail

JsonAccessLogValveback to summary
public JsonAccessLogValve()

Method Detail

addSubkeyedItemsback to summary
private boolean addSubkeyedItems(ListIterator<AbstractAccessLogValve.AccessLogElement> iterator, List<JsonAccessLogValve.JsonWrappedElement> elements, String patternAttribute)
createAccessLogElementback to summary
protected AbstractAccessLogValve.AccessLogElement createAccessLogElement(String name, char pattern)

Overrides org.apache.catalina.valves.AbstractAccessLogValve.createAccessLogElement.

Doc from org.apache.catalina.valves.AbstractAccessLogValve.createAccessLogElement.

Create an AccessLogElement implementation which needs an element name.

Parameters
name:String

Header name

pattern:char

char in the log pattern

Returns:AbstractAccessLogValve.AccessLogElement

the log element

Annotations
@Override
createAccessLogElementback to summary
protected AbstractAccessLogValve.AccessLogElement createAccessLogElement(char pattern)

Overrides org.apache.catalina.valves.AbstractAccessLogValve.createAccessLogElement.

Doc from org.apache.catalina.valves.AbstractAccessLogValve.createAccessLogElement.

Create an AccessLogElement implementation.

Parameters
pattern:char

char in the log pattern

Returns:AbstractAccessLogValve.AccessLogElement

the log element

Annotations
@Override
createLogElementsback to summary
protected AbstractAccessLogValve.AccessLogElement[] createLogElements()

Overrides org.apache.catalina.valves.AbstractAccessLogValve.createLogElements.

Doc from org.apache.catalina.valves.AbstractAccessLogValve.createLogElements.

Parse pattern string and create the array of AccessLogElement.

Returns:AbstractAccessLogValve.AccessLogElement[]

the log elements array

Annotations
@Override
org.apache.catalina.valves back to summary

protected Class JsonAccessLogValve.CharElement

extends Object
implements AccessLogElement
Class Inheritance
All Implemented Interfaces
org.apache.catalina.valves.AbstractAccessLogValve.AccessLogElement

write any char

Field Summary

Modifier and TypeField and Description
private final char

Constructor Summary

AccessConstructor and Description
public
CharElement(char ch)

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

chback to summary
private final char ch

Constructor Detail

CharElementback to summary
public CharElement(char ch)

Method Detail

addElementback to summary
public void addElement(CharArrayWriter buf, Date date, Request request, Response response, long time)

Implements org.apache.catalina.valves.AbstractAccessLogValve.AccessLogElement.addElement.

Annotations
@Override
org.apache.catalina.valves back to summary

private Class JsonAccessLogValve.JsonWrappedElement

extends Object
implements AccessLogElement, CachedElement
Class Inheritance
  • java.lang.Object
  • org.apache.catalina.valves.JsonAccessLogValve.JsonWrappedElement
All Implemented Interfaces
org.apache.catalina.valves.AbstractAccessLogValve.CachedElement, org.apache.catalina.valves.AbstractAccessLogValve.AccessLogElement

Field Summary

Modifier and TypeField and Description
private CharSequence
private AbstractAccessLogValve.AccessLogElement
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
JsonWrappedElement(char pattern, String key, boolean quoteValue, AbstractAccessLogValve.AccessLogElement delegate)

pack-priv
JsonWrappedElement(char pattern, boolean quoteValue, AbstractAccessLogValve.AccessLogElement delegate)

Method Summary

Modifier and TypeMethod and Description
public void
public void
private CharSequence
public AbstractAccessLogValve.AccessLogElement
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeNameback to summary
private CharSequence attributeName
delegateback to summary
private AbstractAccessLogValve.AccessLogElement delegate
quoteValueback to summary
private boolean quoteValue

Constructor Detail

JsonWrappedElementback to summary
pack-priv JsonWrappedElement(char pattern, String key, boolean quoteValue, AbstractAccessLogValve.AccessLogElement delegate)
JsonWrappedElementback to summary
pack-priv JsonWrappedElement(char pattern, boolean quoteValue, AbstractAccessLogValve.AccessLogElement delegate)

Method Detail

addElementback to summary
public void addElement(CharArrayWriter buf, Date date, Request request, Response response, long time)

Implements org.apache.catalina.valves.AbstractAccessLogValve.AccessLogElement.addElement.

Annotations
@Override
cacheback to summary
public void cache(Request request)

Implements org.apache.catalina.valves.AbstractAccessLogValve.CachedElement.cache.

Annotations
@Override
escapeJsonStringback to summary
private CharSequence escapeJsonString(CharSequence nonEscaped)
getDelegateback to summary
public AbstractAccessLogValve.AccessLogElement getDelegate()