Package co.elastic.logging.logback
Class EcsEncoder
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
co.elastic.logging.logback.EcsEncoder
- All Implemented Interfaces:
ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.LifeCycle
public class EcsEncoder
extends ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent>Fields inherited from class ch.qos.logback.core.encoder.EncoderBase
startedFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidaddCustomFields(ch.qos.logback.classic.spi.ILoggingEvent event, StringBuilder builder) Subclasses can override this to add custom fields.voidclose()This method has been removed in logback 1.2.voidThis method has been removed in logback 1.2.byte[]encode(ch.qos.logback.classic.spi.ILoggingEvent event) byte[]byte[]voidinit(OutputStream os) This method has been removed in logback 1.2.voidsetEventDataset(String eventDataset) voidsetIncludeMarkers(boolean includeMarkers) voidsetIncludeOrigin(boolean includeOrigin) voidsetMessageLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> messageLayout) The supplied Layout will be applied specifically to format themessagefield based on the logging event.voidsetServiceEnvironment(String serviceEnvironment) voidsetServiceName(String serviceName) voidsetServiceNodeName(String serviceNodeName) voidsetServiceVersion(String serviceVersion) voidsetStackTraceAsArray(boolean stackTraceAsArray) voidsetThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter) voidstart()Methods inherited from class ch.qos.logback.core.encoder.EncoderBase
isStarted, stopMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Field Details
-
messageLayout
protected ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> messageLayout
-
-
Constructor Details
-
EcsEncoder
public EcsEncoder()
-
-
Method Details
-
headerBytes
public byte[] headerBytes() -
start
public void start()- Specified by:
startin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
startin classch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
init
This method has been removed in logback 1.2. To make this lib backwards compatible with logback 1.1 we have implement this method. -
doEncode
This method has been removed in logback 1.2. To make this lib backwards compatible with logback 1.1 we have implement this method. However, since we compile with 1.2.x, this method is not compiled as an interface method, which means that there won't be type erasure. Therefore, we must use aObjectargument for it to be compatible with 1.1.x.- Throws:
IOException
-
close
This method has been removed in logback 1.2. To make this lib backwards compatible with logback 1.1 we have implement this method.- Throws:
IOException
-
encode
public byte[] encode(ch.qos.logback.classic.spi.ILoggingEvent event) -
addCustomFields
protected void addCustomFields(ch.qos.logback.classic.spi.ILoggingEvent event, StringBuilder builder) Subclasses can override this to add custom fields. The last character in the StringBuilder will be comma when this is called. You must add a comma after each custom field. -
setServiceName
-
setServiceVersion
-
setServiceEnvironment
-
setServiceNodeName
-
setIncludeMarkers
public void setIncludeMarkers(boolean includeMarkers) -
setStackTraceAsArray
public void setStackTraceAsArray(boolean stackTraceAsArray) -
setIncludeOrigin
public void setIncludeOrigin(boolean includeOrigin) -
addAdditionalField
-
setEventDataset
-
setThrowableConverter
public void setThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter) -
setMessageLayout
public void setMessageLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> messageLayout) The supplied Layout will be applied specifically to format themessagefield based on the logging event.- Parameters:
messageLayout-
-