Class AbstractOutputStreamAppender<M extends OutputStreamManager>

Type Parameters:
M - The kind of OutputStreamManager under management
All Implemented Interfaces:
Appender, Filterable, LocationAware, LifeCycle, LifeCycle2
Direct Known Subclasses:
AbstractFileAppender, ConsoleAppender, FileAppender, MemoryMappedFileAppender, OutputStreamAppender, RandomAccessFileAppender, RollingFileAppender, RollingRandomAccessFileAppender, SocketAppender

public abstract class AbstractOutputStreamAppender<M extends OutputStreamManager> extends AbstractAppender
Appends log events as bytes to a byte output stream. The stream encoding is defined in the layout.
  • Field Details

    • immediateFlush

      private final boolean immediateFlush
      Immediate flush means that the underlying writer or output stream will be flushed at the end of each append operation. Immediate flush is slower but ensures that each append request is actually written. If immediateFlush is set to false, then there is a good chance that the last few logs events are not actually written to persistent media if and when the application crashes.
    • manager

      private final M extends OutputStreamManager manager
  • Constructor Details

  • Method Details

    • getImmediateFlush

      public boolean getImmediateFlush()
      Gets the immediate flush setting.
      Returns:
      immediate flush.
    • getManager

      public M getManager()
      Gets the manager.
      Returns:
      the manager.
    • start

      public void start()
      Description copied from class: AbstractFilterable
      Make the Filter available for use.
      Specified by:
      start in interface LifeCycle
      Overrides:
      start in class AbstractFilterable
    • stop

      public boolean stop(long timeout, TimeUnit timeUnit)
      Description copied from class: AbstractFilterable
      Cleanup the Filter.
      Specified by:
      stop in interface LifeCycle2
      Overrides:
      stop in class AbstractFilterable
      Parameters:
      timeout - the maximum time to wait
      timeUnit - the time unit of the timeout argument
      Returns:
      true if the receiver was stopped cleanly and normally, false otherwise.
    • stop

      protected boolean stop(long timeout, TimeUnit timeUnit, boolean changeLifeCycleState)
      Description copied from class: AbstractFilterable
      Cleanup the Filter.
      Overrides:
      stop in class AbstractFilterable
    • append

      public void append(LogEvent event)
      Actual writing occurs here.

      Most subclasses of AbstractOutputStreamAppender will need to override this method.

      Parameters:
      event - The LogEvent.
    • tryAppend

      private void tryAppend(LogEvent event)
    • directEncodeEvent

      protected void directEncodeEvent(LogEvent event)
    • writeByteArrayToManager

      protected void writeByteArrayToManager(LogEvent event)