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
`protected Layout<E>` `layout`

### Fields inherited from class ch.qos.logback.core.encoder.EncoderBase

`outputStream, started`

### Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

`context`

### Constructor Summary

Constructors
Constructor and Description
`LayoutWrappingEncoder()`

### Method Summary

Methods
`void` `close()` This method is called prior to the closing of the underling `OutputStream`.
`void` `doEncode(E event)` Encode and write an event to the appropriate `OutputStream`.
`java.nio.charset.Charset` `getCharset()`
`Layout<E>` `getLayout()`
`void` `init(java.io.OutputStream os)` This method is called when the owning appender starts or whenever output needs to be directed to a new OutputStream, for instance as a result of a rollover.
`boolean` `isImmediateFlush()`
`boolean` `isStarted()`
`void` `setCharset(java.nio.charset.Charset charset)` Set the charset to use when converting the string returned by the layout into bytes.
`void` `setImmediateFlush(boolean immediateFlush)` Sets the immediateFlush option.
`void` `setLayout(Layout<E> layout)`
`void` `start()`
`void` `stop()`

### 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

#### layout

    protected Layout<E> layout

### Constructor Detail

#### LayoutWrappingEncoder

    public LayoutWrappingEncoder()

### Method Detail

#### 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

#### isImmediateFlush

    public boolean isImmediateFlush()

#### getLayout

    public Layout<E> getLayout()

#### setLayout

    public void setLayout(Layout<E> layout)

#### 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 value `null</null> which corresponds to the system's default charset.`

Parameters:
  `charset` -

#### init

    public void init(java.io.OutputStream os)
              throws java.io.IOException

Description copied from interface: `Encoder`
This method is called when the owning appender starts or whenever output needs to be directed to a new OutputStream, for instance as a result of a rollover. Implementing encoders should at the very least remember the OutputStream passed as argument and use it in future operations.

Specified by:
  `init` in interface `Encoder<E>`
Overrides:
  `init` in class `EncoderBase<E>`
Throws:
  `java.io.IOException`

#### close

    public void close()
               throws java.io.IOException

Description copied from interface: `Encoder`
This method is called prior to the closing of the underling `OutputStream`. Implementations MUST not close the underlying `OutputStream` which is the responsibility of the owning appender.

Throws:
  `java.io.IOException`

#### doEncode

    public void doEncode(E event)
                  throws java.io.IOException

Description copied from interface: `Encoder`
Encode and write an event to the appropriate `OutputStream`. Implementations are free to differ writing out of the encoded event and instead write in batches.

Throws:
  `java.io.IOException`

#### isStarted

    public boolean isStarted()

Specified by:
  `isStarted` in interface `LifeCycle`
Overrides:
  `isStarted` in class `EncoderBase<E>`

#### start

    public void start()

Specified by:
  `start` in interface `LifeCycle`
Overrides:
  `start` in class `EncoderBase<E>`

#### stop

    public void stop()

Specified by:
  `stop` in interface `LifeCycle`
Overrides:
  `stop` in class `EncoderBase<E>`