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
|
static String |
IGNORE_FIELD_INDICATOR
Field name to use in logback configuration files
if you want the field to be ignored (not output).
|
protected static org.apache.commons.lang.time.FastDateFormat |
ISO_DATETIME_TIME_ZONE_FORMAT_WITH_MILLIS |
| 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 |
|---|---|
com.fasterxml.jackson.databind.JsonNode |
getCustomFields() |
FieldNamesType |
getFieldNames() |
com.fasterxml.jackson.core.JsonFactory |
getJsonFactory() |
JsonFactoryDecorator |
getJsonFactoryDecorator() |
JsonGeneratorDecorator |
getJsonGeneratorDecorator() |
int |
getShortenedLoggerNameLength() |
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 |
setFieldNames(FieldNamesType fieldNames) |
void |
setIncludeCallerInfo(boolean includeCallerInfo) |
void |
setIncludeContext(boolean includeContext) |
void |
setIncludeMdc(boolean includeMdc) |
void |
setJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator) |
void |
setJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator) |
void |
setShortenedLoggerNameLength(int length) |
void |
start() |
void |
stop() |
protected void |
writeMapEntries(com.fasterxml.jackson.core.JsonGenerator generator,
Map<?,?> map) |
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) |
public static final String IGNORE_FIELD_INDICATOR
protected static final org.apache.commons.lang.time.FastDateFormat ISO_DATETIME_TIME_ZONE_FORMAT_WITH_MILLIS
protected FieldNamesType extends LogstashCommonFieldNames fieldNames
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.LifeCycleprotected void writeValueToGenerator(com.fasterxml.jackson.core.JsonGenerator generator,
ch.qos.logback.classic.spi.ILoggingEvent event,
ch.qos.logback.core.Context context)
throws IOException
IOExceptionpublic 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 boolean isIncludeContext()
public void setIncludeContext(boolean includeContext)
@Deprecated public boolean isEnableContextMap()
Markers.appendEntries(Map) marker instead.@Deprecated public void setEnableContextMap(boolean enableContextMap)
Markers.appendEntries(Map) marker instead.public void stop()
stop in interface ch.qos.logback.core.spi.LifeCyclepublic boolean isStarted()
isStarted in interface ch.qos.logback.core.spi.LifeCyclepublic com.fasterxml.jackson.core.JsonFactory getJsonFactory()
public byte[] writeValueAsBytes(EventType event,
ch.qos.logback.core.Context context)
throws IOException
IOExceptionpublic void writeValueToOutputStream(EventType event,
ch.qos.logback.core.Context context,
OutputStream outputStream)
throws IOException
IOExceptionpublic String writeValueAsString(EventType event, ch.qos.logback.core.Context context) throws IOException
IOExceptionprotected void writeMapEntries(com.fasterxml.jackson.core.JsonGenerator generator,
Map<?,?> map)
throws IOException,
com.fasterxml.jackson.databind.JsonMappingException
IOExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionprotected void writeStringField(com.fasterxml.jackson.core.JsonGenerator generator,
String fieldName,
String fieldValue)
throws IOException
IOExceptionprotected void writeNumberField(com.fasterxml.jackson.core.JsonGenerator generator,
String fieldName,
int fieldValue)
throws IOException
IOExceptionprotected void writeNumberField(com.fasterxml.jackson.core.JsonGenerator generator,
String fieldName,
long fieldValue)
throws IOException
IOExceptionpublic FieldNamesType getFieldNames()
public void setFieldNames(FieldNamesType fieldNames)
public JsonFactoryDecorator getJsonFactoryDecorator()
public void setJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator)
public JsonGeneratorDecorator getJsonGeneratorDecorator()
public void setJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator)
Copyright © 2014. All Rights Reserved.