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
|
Constructor and Description |
---|
LogstashFormatter(ch.qos.logback.core.spi.ContextAware declaredOrigin) |
LogstashFormatter(ch.qos.logback.core.spi.ContextAware declaredOrigin,
boolean includeCallerInfo) |
LogstashFormatter(ch.qos.logback.core.spi.ContextAware declaredOrigin,
boolean includeCallerInfo,
com.fasterxml.jackson.databind.JsonNode customFields) |
Modifier and Type | Method and Description |
---|---|
void |
addExcludeMdcKeyName(String excludedMdcKeyName) |
void |
addIncludeMdcKeyName(String includedMdcKeyName) |
void |
addProvider(JsonProvider<ch.qos.logback.classic.spi.ILoggingEvent> provider) |
protected void |
configureProviderFieldNames() |
com.fasterxml.jackson.databind.JsonNode |
getCustomFields() |
String |
getCustomFieldsAsString() |
List<String> |
getExcludeMdcKeyNames() |
LogstashFieldNames |
getFieldNames() |
List<String> |
getIncludeMdcKeyNames() |
LoggingEventJsonProviders |
getProviders() |
int |
getShortenedLoggerNameLength() |
ch.qos.logback.classic.pattern.ThrowableHandlingConverter |
getThrowableConverter() |
String |
getTimeZone() |
int |
getVersion() |
boolean |
isEnableContextMap()
Deprecated.
When logging, prefer using a
Markers.appendEntries(Map) marker instead. |
boolean |
isIncludeCallerData() |
boolean |
isIncludeCallerInfo()
Deprecated.
use
isIncludeCallerData() (to use the same name that logback uses) |
boolean |
isIncludeContext() |
boolean |
isIncludeMdc() |
boolean |
isWriteVersionAsString() |
void |
setCustomFields(com.fasterxml.jackson.databind.JsonNode customFields) |
void |
setCustomFieldsFromString(String customFields) |
void |
setEnableContextMap(boolean enableContextMap)
Deprecated.
When logging, prefer using a
Markers.appendEntries(Map) marker instead. |
void |
setExcludeMdcKeyNames(List<String> excludeMdcKeyNames) |
void |
setFieldNames(LogstashFieldNames fieldNames) |
void |
setIncludeCallerData(boolean includeCallerData) |
void |
setIncludeCallerInfo(boolean includeCallerInfo)
Deprecated.
use
setIncludeCallerData(boolean) (to use the same name that logback uses) |
void |
setIncludeContext(boolean includeContext) |
void |
setIncludeMdc(boolean includeMdc) |
void |
setIncludeMdcKeyNames(List<String> includeMdcKeyNames) |
void |
setProviders(JsonProviders<ch.qos.logback.classic.spi.ILoggingEvent> jsonProviders) |
void |
setShortenedLoggerNameLength(int length) |
void |
setThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter) |
void |
setTimeZone(String timeZoneId) |
void |
setVersion(int version) |
void |
setWriteVersionAsString(boolean writeVersionAsString) |
void |
start() |
getEncoding, getJsonFactory, getJsonFactoryDecorator, getJsonGeneratorDecorator, isStarted, prepareForDeferredProcessing, setEncoding, setJsonFactoryDecorator, setJsonGeneratorDecorator, stop, writeEventAsBytes, writeEventAsString, writeEventToGenerator, writeEventToOutputStream
protected LogstashFieldNames fieldNames
public LogstashFormatter(ch.qos.logback.core.spi.ContextAware declaredOrigin)
public LogstashFormatter(ch.qos.logback.core.spi.ContextAware declaredOrigin, boolean includeCallerInfo)
public LogstashFormatter(ch.qos.logback.core.spi.ContextAware declaredOrigin, boolean includeCallerInfo, com.fasterxml.jackson.databind.JsonNode customFields)
public void start()
start
in interface ch.qos.logback.core.spi.LifeCycle
start
in class CompositeJsonFormatter<ch.qos.logback.classic.spi.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)public String getCustomFieldsAsString()
public void setCustomFieldsFromString(String customFields)
public void setCustomFields(com.fasterxml.jackson.databind.JsonNode customFields)
public com.fasterxml.jackson.databind.JsonNode getCustomFields()
public int getShortenedLoggerNameLength()
public void setShortenedLoggerNameLength(int length)
public boolean isIncludeMdc()
public void setIncludeMdc(boolean includeMdc)
public void addIncludeMdcKeyName(String includedMdcKeyName)
public void addExcludeMdcKeyName(String excludedMdcKeyName)
public boolean isIncludeContext()
public void setIncludeContext(boolean includeContext)
public ch.qos.logback.classic.pattern.ThrowableHandlingConverter getThrowableConverter()
public void setThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter)
public int getVersion()
public void setVersion(int version)
public boolean isWriteVersionAsString()
public void setWriteVersionAsString(boolean writeVersionAsString)
@Deprecated public boolean isEnableContextMap()
Markers.appendEntries(Map)
marker instead.@Deprecated public void setEnableContextMap(boolean enableContextMap)
Markers.appendEntries(Map)
marker instead.public void addProvider(JsonProvider<ch.qos.logback.classic.spi.ILoggingEvent> provider)
public LoggingEventJsonProviders getProviders()
getProviders
in class CompositeJsonFormatter<ch.qos.logback.classic.spi.ILoggingEvent>
public LogstashFieldNames getFieldNames()
public void setFieldNames(LogstashFieldNames fieldNames)
public String getTimeZone()
public void setTimeZone(String timeZoneId)
public void setProviders(JsonProviders<ch.qos.logback.classic.spi.ILoggingEvent> jsonProviders)
setProviders
in class LoggingEventCompositeJsonFormatter
Copyright © 2017. All Rights Reserved.