public class LogstashFormatter extends Object
Modifier and Type | Field and Description |
---|---|
protected ch.qos.logback.core.spi.ContextAware |
contextAware |
protected FieldNamesType |
fieldNames
The field names to use when writing the standard event fields
|
protected org.apache.commons.lang.time.FastDateFormat |
isoDateTimeTimeZoneFormatWithMillis
Used to format timestamps.
|
Constructor and Description |
---|
LogstashFormatter(ch.qos.logback.core.spi.ContextAware contextAware) |
LogstashFormatter(ch.qos.logback.core.spi.ContextAware contextAware,
boolean includeCallerInfo) |
LogstashFormatter(ch.qos.logback.core.spi.ContextAware contextAware,
boolean includeCallerInfo,
com.fasterxml.jackson.databind.JsonNode customFields) |
Modifier and Type | Method and Description |
---|---|
void |
addExcludeMdcKeyName(String excludedMdcKeyName) |
void |
addIncludeMdcKeyName(String includedMdcKeyName) |
com.fasterxml.jackson.databind.JsonNode |
getCustomFields() |
List<String> |
getExcludeMdcKeyNames() |
FieldNamesType |
getFieldNames() |
List<String> |
getIncludeMdcKeyNames() |
com.fasterxml.jackson.core.JsonFactory |
getJsonFactory() |
JsonFactoryDecorator |
getJsonFactoryDecorator() |
JsonGeneratorDecorator |
getJsonGeneratorDecorator() |
int |
getShortenedLoggerNameLength() |
ch.qos.logback.classic.pattern.ThrowableHandlingConverter |
getThrowableConverter() |
String |
getTimeZone() |
boolean |
isEnableContextMap()
Deprecated.
When logging, prefer using a
Markers.appendEntries(Map) marker instead. |
boolean |
isIncludeCallerInfo() |
boolean |
isIncludeContext() |
boolean |
isIncludeMdc() |
boolean |
isStarted() |
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(FieldNamesType fieldNames) |
void |
setIncludeCallerInfo(boolean includeCallerInfo) |
void |
setIncludeContext(boolean includeContext) |
void |
setIncludeMdc(boolean includeMdc) |
void |
setIncludeMdcKeyNames(List<String> includeMdcKeyNames) |
void |
setJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator) |
void |
setJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator) |
void |
setShortenedLoggerNameLength(int length) |
void |
setThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter) |
void |
setTimeZone(String timeZoneId) |
void |
start() |
void |
stop() |
protected void |
writeMapEntries(com.fasterxml.jackson.core.JsonGenerator generator,
Map<?,?> map) |
protected void |
writeMapStringFields(com.fasterxml.jackson.core.JsonGenerator generator,
String fieldName,
Map<String,String> map)
Writes a map as String fields to the generator if and only if the fieldName and values are not null.
|
protected void |
writeNumberField(com.fasterxml.jackson.core.JsonGenerator generator,
String fieldName,
int fieldValue)
Writes the field to the generator if and only if the fieldName is not null.
|
protected void |
writeNumberField(com.fasterxml.jackson.core.JsonGenerator generator,
String fieldName,
long fieldValue)
Writes the field to the generator if and only if the fieldName is not null.
|
protected void |
writeStringField(com.fasterxml.jackson.core.JsonGenerator generator,
String fieldName,
String fieldValue)
Writes the field to the generator if and only if the fieldName and fieldValue are not null.
|
byte[] |
writeValueAsBytes(EventType event,
ch.qos.logback.core.Context context) |
String |
writeValueAsString(EventType event,
ch.qos.logback.core.Context context) |
protected void |
writeValueToGenerator(com.fasterxml.jackson.core.JsonGenerator generator,
ch.qos.logback.classic.spi.ILoggingEvent event,
ch.qos.logback.core.Context context) |
void |
writeValueToOutputStream(EventType event,
ch.qos.logback.core.Context context,
OutputStream outputStream) |
protected FieldNamesType extends LogstashCommonFieldNames fieldNames
protected org.apache.commons.lang.time.FastDateFormat isoDateTimeTimeZoneFormatWithMillis
protected final ch.qos.logback.core.spi.ContextAware contextAware
public LogstashFormatter(ch.qos.logback.core.spi.ContextAware contextAware)
public LogstashFormatter(ch.qos.logback.core.spi.ContextAware contextAware, boolean includeCallerInfo)
public LogstashFormatter(ch.qos.logback.core.spi.ContextAware contextAware, boolean includeCallerInfo, com.fasterxml.jackson.databind.JsonNode customFields)
public void start()
start
in interface ch.qos.logback.core.spi.LifeCycle
public void stop()
stop
in interface ch.qos.logback.core.spi.LifeCycle
protected void writeValueToGenerator(com.fasterxml.jackson.core.JsonGenerator generator, ch.qos.logback.classic.spi.ILoggingEvent event, ch.qos.logback.core.Context context) throws IOException
IOException
public boolean isIncludeCallerInfo()
public void setIncludeCallerInfo(boolean includeCallerInfo)
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)
@Deprecated public boolean isEnableContextMap()
Markers.appendEntries(Map)
marker instead.@Deprecated public void setEnableContextMap(boolean enableContextMap)
Markers.appendEntries(Map)
marker instead.public boolean isStarted()
isStarted
in interface ch.qos.logback.core.spi.LifeCycle
public com.fasterxml.jackson.core.JsonFactory getJsonFactory()
public byte[] writeValueAsBytes(EventType event, ch.qos.logback.core.Context context) throws IOException
IOException
public void writeValueToOutputStream(EventType event, ch.qos.logback.core.Context context, OutputStream outputStream) throws IOException
IOException
public String writeValueAsString(EventType event, ch.qos.logback.core.Context context) throws IOException
IOException
protected void writeMapEntries(com.fasterxml.jackson.core.JsonGenerator generator, Map<?,?> map) throws IOException, com.fasterxml.jackson.databind.JsonMappingException
IOException
com.fasterxml.jackson.databind.JsonMappingException
protected void writeMapStringFields(com.fasterxml.jackson.core.JsonGenerator generator, String fieldName, Map<String,String> map) throws IOException, com.fasterxml.jackson.databind.JsonMappingException
IOException
com.fasterxml.jackson.databind.JsonMappingException
protected void writeStringField(com.fasterxml.jackson.core.JsonGenerator generator, String fieldName, String fieldValue) throws IOException
IOException
protected void writeNumberField(com.fasterxml.jackson.core.JsonGenerator generator, String fieldName, int fieldValue) throws IOException
IOException
protected void writeNumberField(com.fasterxml.jackson.core.JsonGenerator generator, String fieldName, long fieldValue) throws IOException
IOException
public FieldNamesType getFieldNames()
public void setFieldNames(FieldNamesType fieldNames)
public JsonFactoryDecorator getJsonFactoryDecorator()
public void setJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator)
public JsonGeneratorDecorator getJsonGeneratorDecorator()
public void setJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator)
public String getTimeZone()
public void setTimeZone(String timeZoneId)
Copyright © 2015. All Rights Reserved.