public class LogstashEncoder
extends ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
Constructor and Description |
---|
LogstashEncoder() |
Modifier and Type | Method and Description |
---|---|
void |
addExcludeMdcKeyName(String excludedMdcKeyName) |
void |
addIncludeMdcKeyName(String includedMdcKeyName) |
void |
close() |
void |
doEncode(ch.qos.logback.classic.spi.ILoggingEvent event) |
String |
getCustomFields() |
List<String> |
getExcludeMdcKeyNames() |
LogstashFieldNames |
getFieldNames() |
protected LogstashFormatter |
getFormatter() |
List<String> |
getIncludeMdcKeyNames() |
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 |
isImmediateFlush() |
boolean |
isIncludeCallerInfo() |
boolean |
isIncludeContext() |
boolean |
isIncludeMdc() |
void |
setCustomFields(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 |
setImmediateFlush(boolean immediateFlush) |
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() |
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
public void doEncode(ch.qos.logback.classic.spi.ILoggingEvent event) throws IOException
IOException
public void start()
start
in interface ch.qos.logback.core.spi.LifeCycle
start
in class ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
public void stop()
stop
in interface ch.qos.logback.core.spi.LifeCycle
stop
in class ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
public void close() throws IOException
IOException
public boolean isImmediateFlush()
public void setImmediateFlush(boolean immediateFlush)
public boolean isIncludeCallerInfo()
public void setIncludeCallerInfo(boolean includeCallerInfo)
public void setCustomFields(String customFields)
public String getCustomFields()
public LogstashFieldNames getFieldNames()
public void setFieldNames(LogstashFieldNames fieldNames)
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)
@Deprecated public void setEnableContextMap(boolean enableContextMap)
Markers.appendEntries(Map)
marker instead.If set to true the encoder will search logging event array and if the last item is a Map, entries will be included in the message.
Example:
log.info("Service started in {} seconds", duration / 1000, Collections.singletonMap("duration", duration))Will produce:
{ "@timestamp": "2014-06-04T15:26:14.464+02:00", "message": "Service started in 8 seconds", "level": "INFO", "duration": 8496 ...
enableContextMap
- true
to enable context map@Deprecated public boolean isEnableContextMap()
Markers.appendEntries(Map)
marker instead.public JsonFactoryDecorator getJsonFactoryDecorator()
public void setJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator)
public JsonGeneratorDecorator getJsonGeneratorDecorator()
public void setJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator)
public ch.qos.logback.classic.pattern.ThrowableHandlingConverter getThrowableConverter()
public void setThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter)
public String getTimeZone()
public void setTimeZone(String timeZoneId)
protected LogstashFormatter getFormatter()
Copyright © 2015. All Rights Reserved.