Class AbstractJsonPatternParser<Event>
java.lang.Object
net.logstash.logback.pattern.AbstractJsonPatternParser<Event>
- Type Parameters:
Event- - type of the event (ILoggingEvent, IAccessEvent)
- Direct Known Subclasses:
AccessEventJsonPatternParser, LoggingEventJsonPatternParser
Parser that takes a JSON pattern, resolves all the conversion specifiers and returns an instance
of NodeWriter that, when its write() method is invoked, produces JSON defined by the parsed pattern.
- Author:
- Dmitry Andrianov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static classprotected classprotected static classprotected classstatic classprotected static classprotected static classprotected static interfaceprotected classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternPattern used to parse and detectAbstractJsonPatternParser.Operationin a string. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddOperation(String name, AbstractJsonPatternParser.Operation<?> operation) Register a newAbstractJsonPatternParser.Operationand bind it to the givenname.protected PatternLayoutAdapter<Event> buildLayout(String format) Initialize a PatternLayout with the supplied format and throw anIllegalArgumentExceptionif the format is invalid.protected abstract PatternLayoutBase<Event> Create a PatternLayout instance of the appropriate type.booleanWhentrue, fields whose values are considered empty will be omitted from JSON output.protected ValueGetter<Event, String> makeLayoutValueGetter(String data) Parse a JSON pattern and produce the correspondingNodeWriter.voidsetOmitEmptyFields(boolean omitEmptyFields) Whentrue, fields whose values are considered empty will be omitted from JSON output.
-
Field Details
-
OPERATION_PATTERN
Pattern used to parse and detectAbstractJsonPatternParser.Operationin a string. An operation starts with a #, followed by a name and a pair of {} with possible arguments in between.
-
-
Method Details
-
addOperation
Register a newAbstractJsonPatternParser.Operationand bind it to the givenname.- Parameters:
name- the name of the operationoperation- theAbstractJsonPatternParser.Operationinstance
-
makeLayoutValueGetter
-
buildLayout
Initialize a PatternLayout with the supplied format and throw anIllegalArgumentExceptionif the format is invalid.- Parameters:
format- the pattern layout format- Returns:
- a configured and started
PatternLayoutAdapterinstance around the supplied format - Throws:
IllegalArgumentException- if the supplied format is not a valid PatternLayout
-
createLayout
Create a PatternLayout instance of the appropriate type. The returned instance will be further configured with the context and appropriate pattern then started.- Returns:
- an unstarted
PatternLayoutBaseinstance
-
parse
public NodeWriter<Event> parse(String pattern) throws AbstractJsonPatternParser.JsonPatternException Parse a JSON pattern and produce the correspondingNodeWriter. Returns null if the pattern is invalid, null or empty. An error status is logged when the pattern is invalid and parsing failed.- Parameters:
pattern- the JSON pattern to parse- Returns:
- a
NodeWriterconfigured according to the pattern - Throws:
AbstractJsonPatternParser.JsonPatternException- denotes an invalid pattern
-
isOmitEmptyFields
public boolean isOmitEmptyFields()Whentrue, fields whose values are considered empty will be omitted from JSON output.- Returns:
trueif fields with empty values are omitted from JSON output
-
setOmitEmptyFields
public void setOmitEmptyFields(boolean omitEmptyFields) Whentrue, fields whose values are considered empty will be omitted from JSON output.- Parameters:
omitEmptyFields- whether fields with empty value should be omitted or not
-