public class LogstashFormatter extends LoggingEventCompositeJsonFormatter
LoggingEventCompositeJsonFormatter
that contains a common
pre-defined set of JsonProvider
s.
The included providers are configured via properties on this
formatter, rather than configuring the providers directly.
This leads to a somewhat simpler configuration definitions.
You cannot remove any of the pre-defined providers, but
you can add additional providers via addProvider(JsonProvider)
.
If you would like full control over the providers, you
should instead use LoggingEventCompositeJsonFormatter
directly.Modifier and Type | Field and Description |
---|---|
protected LogstashFieldNames |
fieldNames
The field names to use when writing the standard event fields
|
context
Constructor and Description |
---|
LogstashFormatter(ContextAware declaredOrigin) |
LogstashFormatter(ContextAware declaredOrigin,
boolean includeCallerInfo) |
LogstashFormatter(ContextAware declaredOrigin,
boolean includeCallerInfo,
JsonNode customFields) |
getEncoding, getJsonFactory, getJsonFactoryDecorator, getJsonGeneratorDecorator, isFindAndRegisterJacksonModules, isStarted, prepareForDeferredProcessing, setEncoding, setFindAndRegisterJacksonModules, setJsonFactoryDecorator, setJsonGeneratorDecorator, stop, writeEventAsBytes, writeEventAsString, writeEventToGenerator, writeEventToOutputStream
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
protected LogstashFieldNames fieldNames
public LogstashFormatter(ContextAware declaredOrigin)
public LogstashFormatter(ContextAware declaredOrigin, boolean includeCallerInfo)
public LogstashFormatter(ContextAware declaredOrigin, boolean includeCallerInfo, JsonNode customFields)
public void start()
start
in interface LifeCycle
start
in class CompositeJsonFormatter<ILoggingEvent>
protected void configureProviderFieldNames()
public boolean isIncludeCallerData()
public void setIncludeCallerData(boolean includeCallerData)
@Deprecated public boolean isIncludeCallerInfo()
isIncludeCallerData()
(to use the same name that logback uses)@Deprecated public void setIncludeCallerInfo(boolean includeCallerInfo)
setIncludeCallerData(boolean)
(to use the same name that logback uses)includeCallerInfo
- true if the caller info should be includedpublic String getCustomFieldsAsString()
public void setCustomFieldsFromString(String customFields)
public void setCustomFields(JsonNode customFields)
public JsonNode getCustomFields()
public int getShortenedLoggerNameLength()
public void setShortenedLoggerNameLength(int length)
public boolean isIncludeMdc()
public void setIncludeMdc(boolean includeMdc)
public boolean isIncludeTags()
public void setIncludeTags(boolean includeTags)
public boolean isIncludeStructuredArguments()
public void setIncludeStructuredArguments(boolean includeStructuredArguments)
public boolean isIncludeNonStructuredArguments()
public void setIncludeNonStructuredArguments(boolean includeNonStructuredArguments)
public String getNonStructuredArgumentsFieldPrefix()
public void setNonStructuredArgumentsFieldPrefix(String nonStructuredArgumentsFieldPrefix)
public void addIncludeMdcKeyName(String includedMdcKeyName)
public void addExcludeMdcKeyName(String excludedMdcKeyName)
public void addMdcKeyFieldName(String mdcKeyFieldName)
public boolean isIncludeContext()
public void setIncludeContext(boolean includeContext)
public ThrowableHandlingConverter getThrowableConverter()
public void setThrowableConverter(ThrowableHandlingConverter throwableConverter)
public String getVersion()
public void setVersion(String version)
@Deprecated public boolean isWriteVersionAsString()
isWriteVersionAsInteger()
@Deprecated public void setWriteVersionAsString(boolean writeVersionAsString)
setWriteVersionAsInteger(boolean)
writeVersionAsString
- true if the version should be written as a stringpublic boolean isWriteVersionAsInteger()
public void setWriteVersionAsInteger(boolean writeVersionAsInteger)
@Deprecated public boolean isEnableContextMap()
Markers.appendEntries(Map)
marker instead.@Deprecated public void setEnableContextMap(boolean enableContextMap)
Markers.appendEntries(Map)
marker instead.enableContextMap
- true if the last Map argument should be appendedpublic String getMessageSplitRegex()
public void setMessageSplitRegex(String messageSplitRegex)
The allowed values are:
For example, if this parameter is set to the regex #+
, then the logging statement:
log.info("First line##Second line###Third line")will produce:
{ ... "message": [ "First line", "Second line", "Third line" ], ... }
messageSplitRegex
- The regex used to split the message textpublic void addProvider(JsonProvider<ILoggingEvent> provider)
public LoggingEventJsonProviders getProviders()
getProviders
in class CompositeJsonFormatter<ILoggingEvent>
public LogstashFieldNames getFieldNames()
public void setFieldNames(LogstashFieldNames fieldNames)
public String getTimeZone()
public void setTimeZone(String timeZoneId)
public String getTimestampPattern()
public void setTimestampPattern(String pattern)
public void setProviders(JsonProviders<ILoggingEvent> jsonProviders)
setProviders
in class LoggingEventCompositeJsonFormatter
Copyright © 2020. All rights reserved.