public class MdcJsonProvider extends AbstractFieldJsonProvider<ILoggingEvent> implements FieldNamesAware<LogstashFieldNames>
MDC properties in the JSON output according to
includeMdcKeyNames and excludeMdcKeyNames.
There are three valid combinations of includeMdcKeyNames
and excludeMdcKeyNames:
includeMdcKeyNames and excludeMdcKeyNames
are both empty, then all entries will be included.includeMdcKeyNames is not empty and
excludeMdcKeyNames is empty, then only those entries
with key names in includeMdcKeyNames will be included.includeMdcKeyNames is empty and
excludeMdcKeyNames is not empty, then all entries except those
with key names in excludeMdcKeyNames will be included.It is a configuration error for both includeMdcKeyNames
and excludeMdcKeyNames to be not empty.
By default, for each entry in the MDC, the MDC key is output as the field name.
This can be changed by specifying an explicit field name to use for an MDC key
via addMdcKeyFieldName(String)
If the fieldName is set, then the properties will be written to that field as a subobject. Otherwise, the properties are written inline.
context| Constructor and Description |
|---|
MdcJsonProvider() |
| Modifier and Type | Method and Description |
|---|---|
void |
addExcludeMdcKeyName(String excludedMdcKeyName) |
void |
addIncludeMdcKeyName(String includedMdcKeyName) |
void |
addMdcKeyFieldName(String mdcKeyFieldName)
Adds the given mdcKeyFieldName entry in the form mdcKeyName=fieldName
to use an alternative field name for an MDC key.
|
List<String> |
getExcludeMdcKeyNames() |
List<String> |
getIncludeMdcKeyNames() |
Map<String,String> |
getMdcKeyFieldNames() |
void |
setExcludeMdcKeyNames(List<String> excludeMdcKeyNames) |
void |
setFieldNames(LogstashFieldNames fieldNames) |
void |
setIncludeMdcKeyNames(List<String> includeMdcKeyNames) |
void |
start() |
void |
writeTo(JsonGenerator generator,
ILoggingEvent event)
Writes information about the event,
to the given generator.
|
getFieldName, setFieldNameisStarted, prepareForDeferredProcessing, stopaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContextpublic void start()
start in interface LifeCyclestart in class AbstractJsonProvider<ILoggingEvent>public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException
JsonProviderwriteTo in interface JsonProvider<ILoggingEvent>IOExceptionpublic void setFieldNames(LogstashFieldNames fieldNames)
setFieldNames in interface FieldNamesAware<LogstashFieldNames>public void addIncludeMdcKeyName(String includedMdcKeyName)
public void addExcludeMdcKeyName(String excludedMdcKeyName)
public void addMdcKeyFieldName(String mdcKeyFieldName)
mdcKeyFieldName - a string in the form mdcKeyName=fieldName that identifies what field name to use for a specific MDC key.Copyright © 2020. All rights reserved.