Class CompositeJsonEncoder<Event extends DeferredProcessingAware>
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.encoder.EncoderBase<Event>
net.logstash.logback.encoder.CompositeJsonEncoder<Event>
- All Implemented Interfaces:
Encoder<Event>, ContextAware, LifeCycle, StreamingEncoder<Event>
- Direct Known Subclasses:
AccessEventCompositeJsonEncoder, LoggingEventCompositeJsonEncoder
public abstract class CompositeJsonEncoder<Event extends DeferredProcessingAware>
extends EncoderBase<Event>
implements StreamingEncoder<Event>
-
Field Summary
Fields inherited from class EncoderBase
startedFields inherited from class ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDecorator(Decorator<?> decorator) protected abstract AbstractCompositeJsonFormatter<Event> byte[]voidencode(Event event, OutputStream outputStream) byte[]protected AbstractCompositeJsonFormatter<Event> intbyte[]voidsetDataFormat(String dataFormat) voidsetDataFormatFactory(DataFormatFactory dataFormatFactory) voidsetEncoding(String encodingName) The character encoding to use (default = "UTF-8").voidsetFindAndRegisterJacksonModules(boolean findAndRegisterJacksonModules) voidsetLineSeparator(String lineSeparator) Sets which lineSeparator to use between events.voidsetMinBufferSize(int minBufferSize) The minimum size of the byte buffer used when encoding events.voidvoidsetProviders(JsonProviders<Event> jsonProviders) voidvoidstart()voidstop()Methods inherited from class EncoderBase
isStartedMethods inherited from class ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
CompositeJsonEncoder
public CompositeJsonEncoder()
-
-
Method Details
-
createFormatter
-
encode
- Specified by:
encodein interfaceStreamingEncoder<Event extends DeferredProcessingAware>- Throws:
IOException
-
encode
- Specified by:
encodein interfaceEncoder<Event extends DeferredProcessingAware>
-
start
public void start()- Specified by:
startin interfaceLifeCycle- Overrides:
startin classEncoderBase<Event extends DeferredProcessingAware>
-
stop
public void stop()- Specified by:
stopin interfaceLifeCycle- Overrides:
stopin classEncoderBase<Event extends DeferredProcessingAware>
-
headerBytes
public byte[] headerBytes()- Specified by:
headerBytesin interfaceEncoder<Event extends DeferredProcessingAware>
-
getProviders
-
setProviders
-
getDataFormat
-
setDataFormat
-
getDataFormatFactory
-
setDataFormatFactory
-
addDecorator
-
getTokenStreamFactoryBuilderDecorator
-
getMapperBuilderDecorator
-
getJsonGeneratorDecorator
-
getEncoding
-
setEncoding
The character encoding to use (default = "UTF-8"). Must an encoding supported byJsonEncoding- Parameters:
encodingName- encoding name
-
setFindAndRegisterJacksonModules
public void setFindAndRegisterJacksonModules(boolean findAndRegisterJacksonModules) -
getLineSeparator
-
setLineSeparator
Sets which lineSeparator to use between events.The following values have special meaning:
nullor empty string = no new line.- "
SYSTEM" = operating system new line (default). - "
UNIX" = unix line ending (\n). - "
WINDOWS" = windows line ending\r\n).
Any other value will be used as given as the lineSeparator.
- Parameters:
lineSeparator- the line separator
-
getMinBufferSize
public int getMinBufferSize() -
setMinBufferSize
public void setMinBufferSize(int minBufferSize) The minimum size of the byte buffer used when encoding events.The buffer automatically grows above the
#minBufferSizewhen needed to accommodate with larger events. However, only the firstminBufferSizebytes will be reused by subsequent invocations. It is therefore strongly advised to set the minimum size at least equal to the average size of the encoded events to reduce unnecessary memory allocations and reduce pressure on the garbage collector.Note: changes to the buffer size will not be taken into account after the encoder is started.
- Parameters:
minBufferSize- minimum size of the byte buffer (in bytes)
-
getFormatter
-
getPrefix
-
setPrefix
-
getSuffix
-
setSuffix
-