Package net.logstash.logback.pattern
Class EnhancedPropertyConverter
java.lang.Object
ch.qos.logback.core.pattern.Converter<E>
ch.qos.logback.core.pattern.FormattingConverter<E>
ch.qos.logback.core.pattern.DynamicConverter<ILoggingEvent>
ch.qos.logback.classic.pattern.ClassicConverter
net.logstash.logback.pattern.EnhancedPropertyConverter
- All Implemented Interfaces:
ContextAware
,LifeCycle
Variation of the Logback
PropertyConverter
with the option to specify a default
value to use when the property does not exist instead of returning null
as does
the original Logback implementation.
The default value is optional and can be specified using the :-
operator as
in Bash shell. For example, assuming the property "foo" is not defined, %property{foo:-bar}
will return bar
.
If no optional value is declared, the converter returns an empty string instead of null
if the property is not defined.
The property resolution mechanism is the same as the Logback implementation. The property is first looked up in the context associated with the logging event. If not found, the property is searched in the System environment.
- Author:
- brenuart
-
Field Summary
Fields inherited from class ch.qos.logback.core.pattern.DynamicConverter
started
-
Constructor Summary
-
Method Summary
Methods inherited from class ch.qos.logback.core.pattern.DynamicConverter
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getFirstOption, getOptionList, isStarted, setContext, setOptionList, stop
Methods inherited from class ch.qos.logback.core.pattern.FormattingConverter
getFormattingInfo, setFormattingInfo, write
-
Constructor Details
-
EnhancedPropertyConverter
public EnhancedPropertyConverter()
-
-
Method Details
-
start
public void start()- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classDynamicConverter<ILoggingEvent>
-
convert
- Specified by:
convert
in classConverter<ILoggingEvent>
-