Package ch.qos.logback.core.encoder
Class LayoutWrappingEncoder<E>
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.encoder.EncoderBase<E>
-
- ch.qos.logback.core.encoder.LayoutWrappingEncoder<E>
-
- All Implemented Interfaces:
Encoder<E>,ContextAware,LifeCycle
- Direct Known Subclasses:
PatternLayoutEncoderBase
public class LayoutWrappingEncoder<E> extends EncoderBase<E>
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.charset.CharsetcharsetThe charset to use when converting a String into bytes.(package private) java.lang.BooleanimmediateFlushprotected Layout<E>layout(package private) ContextAwareparent-
Fields inherited from class ch.qos.logback.core.encoder.EncoderBase
started
-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description LayoutWrappingEncoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendIfNotNull(java.lang.StringBuilder sb, java.lang.String s)private byte[]convertToBytes(java.lang.String s)byte[]encode(E event)Encode an event as bytes.byte[]footerBytes()Get footer bytes.java.nio.charset.CharsetgetCharset()Layout<E>getLayout()byte[]headerBytes()Get header bytes.booleanisStarted()voidsetCharset(java.nio.charset.Charset charset)Set the charset to use when converting the string returned by the layout into bytes.voidsetImmediateFlush(boolean immediateFlush)Sets the immediateFlush option.voidsetLayout(Layout<E> layout)voidsetParent(ContextAware parent)This method allows RollingPolicy implementations to be aware of their containing appender.voidstart()voidstop()-
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
-
-
-
-
Field Detail
-
charset
private java.nio.charset.Charset charset
The charset to use when converting a String into bytes. By default this property has the valuenull which corresponds to the system's default charset.
-
parent
ContextAware parent
-
immediateFlush
java.lang.Boolean immediateFlush
-
-
Method Detail
-
getCharset
public java.nio.charset.Charset getCharset()
-
setCharset
public void setCharset(java.nio.charset.Charset charset)
Set the charset to use when converting the string returned by the layout into bytes. By default this property has the valuenull which corresponds to the system's default charset.- Parameters:
charset-
-
setImmediateFlush
public void setImmediateFlush(boolean immediateFlush)
Sets the immediateFlush option. The default value for immediateFlush is 'true'. If set to true, the doEncode() method will immediately flush the underlying OutputStream. Although immediate flushing is safer, it also significantly degrades logging throughput.- Since:
- 1.0.3
-
headerBytes
public byte[] headerBytes()
Description copied from interface:EncoderGet header bytes. This method is typically called upon opening of an output stream.- Returns:
- header bytes. Null values are allowed.
-
footerBytes
public byte[] footerBytes()
Description copied from interface:EncoderGet footer bytes. This method is typically called prior to the closing of the stream where events are written.- Returns:
- footer bytes. Null values are allowed.
-
convertToBytes
private byte[] convertToBytes(java.lang.String s)
-
encode
public byte[] encode(E event)
Description copied from interface:EncoderEncode an event as bytes.
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceLifeCycle- Overrides:
isStartedin classEncoderBase<E>
-
start
public void start()
- Specified by:
startin interfaceLifeCycle- Overrides:
startin classEncoderBase<E>
-
stop
public void stop()
- Specified by:
stopin interfaceLifeCycle- Overrides:
stopin classEncoderBase<E>
-
appendIfNotNull
private void appendIfNotNull(java.lang.StringBuilder sb, java.lang.String s)
-
setParent
public void setParent(ContextAware parent)
This method allows RollingPolicy implementations to be aware of their containing appender.- Parameters:
parent-
-
-