Package net.logstash.logback.encoder
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 ch.qos.logback.core.encoder.EncoderBase
started
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractCompositeJsonFormatter<Event>
byte[]
void
encode
(Event event, OutputStream outputStream) byte[]
protected AbstractCompositeJsonFormatter<Event>
int
byte[]
void
setEncoding
(String encodingName) The character encoding to use (default = "UTF-8
").void
setFindAndRegisterJacksonModules
(boolean findAndRegisterJacksonModules) void
setJsonFactoryDecorator
(JsonFactoryDecorator jsonFactoryDecorator) void
setJsonGeneratorDecorator
(JsonGeneratorDecorator jsonGeneratorDecorator) void
setLineSeparator
(String lineSeparator) Sets which lineSeparator to use between events.void
setMinBufferSize
(int minBufferSize) The minimum size of the byte buffer used when encoding events.void
void
setProviders
(JsonProviders<Event> jsonProviders) void
void
start()
void
stop()
Methods inherited from class ch.qos.logback.core.encoder.EncoderBase
isStarted
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
CompositeJsonEncoder
public CompositeJsonEncoder()
-
-
Method Details
-
createFormatter
-
encode
- Specified by:
encode
in interfaceStreamingEncoder<Event extends DeferredProcessingAware>
- Throws:
IOException
-
encode
- Specified by:
encode
in interfaceEncoder<Event extends DeferredProcessingAware>
-
start
public void start()- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classEncoderBase<Event extends DeferredProcessingAware>
-
stop
public void stop()- Specified by:
stop
in interfaceLifeCycle
- Overrides:
stop
in classEncoderBase<Event extends DeferredProcessingAware>
-
headerBytes
public byte[] headerBytes()- Specified by:
headerBytes
in interfaceEncoder<Event extends DeferredProcessingAware>
-
getProviders
-
setProviders
-
getJsonFactoryDecorator
-
setJsonFactoryDecorator
-
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) -
setJsonGeneratorDecorator
-
getLineSeparator
-
setLineSeparator
Sets which lineSeparator to use between events.The following values have special meaning:
null
or 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
#minBufferSize
when needed to accommodate with larger events. However, only the firstminBufferSize
bytes 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
-