Class AbstractWriterAppender<M extends WriterManager>

Type Parameters:
M - The kind of WriterManager under management
All Implemented Interfaces:
Appender, Filterable, LocationAware, LifeCycle, LifeCycle2
Direct Known Subclasses:
WriterAppender

public abstract class AbstractWriterAppender<M extends WriterManager> extends AbstractAppender
Appends log events as strings to a writer.
  • Field Details

    • immediateFlush

      protected final boolean immediateFlush
      Immediate flush means that the underlying writer 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.
  • Constructor Details

    • AbstractWriterAppender

      protected AbstractWriterAppender(String name, StringLayout layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, Property[] properties, M manager)
      Instantiates.
      Parameters:
      name - The name of the Appender.
      layout - The layout to format the message.
      filter - The filter to associate with the Appender.
      ignoreExceptions - If true, exceptions will be logged and suppressed. If false errors will be logged and then passed to the application.
      immediateFlush - Underlying writer will be flushed at the end of each append operation.
      properties - Optional properties.
      manager - The OutputStreamManager.
    • AbstractWriterAppender

      @Deprecated protected AbstractWriterAppender(String name, StringLayout layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, M manager)
      Instantiates.
      Parameters:
      name - The name of the Appender.
      layout - The layout to format the message.
      manager - The OutputStreamManager.
  • Method Details

    • append

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

      Most subclasses will need to override this method.

      Parameters:
      event - The LogEvent.
    • getManager

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

      public StringLayout getStringLayout()
    • 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.