Interface Appender<E>

Type Parameters:
E - the event type accepted by this appender
All Superinterfaces:
ContextAware, FilterAttachable<E>, LifeCycle
All Known Implementing Classes:
AbstractServerSocketAppender, AbstractSocketAppender, AbstractSSLSocketAppender, AppenderBase, AsyncAppender, AsyncAppenderBase, ConsoleAppender, CyclicBufferAppender, DelayingListAppender, FileAppender, ListAppender, NOPAppender, NPEAppender, OutputStreamAppender, RollingFileAppender, ServerSocketAppender, SiftingAppender, SiftingAppenderBase, SMTPAppender, SMTPAppenderBase, SocketAppender, SSLServerSocketAppender, SSLServerSocketAppenderBase, SSLSocketAppender, StringListAppender, SyslogAppender, SyslogAppenderBase, UnsynchronizedAppenderBase, WithLayoutListAppender

public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachable<E>
Contract for components responsible for delivering logging events to their final destination (console, file, remote server, etc.).

Implementations are typically configured and managed by a LoggerContext. The type parameter E represents the event type the appender consumes (for example a log event object). Implementations should honor lifecycle methods from LifeCycle and may be ContextAware and FilterAttachable to support contextual information and filtering.

Concurrency: appenders are generally invoked by multiple threads. Implementations must ensure thread-safety where applicable (for example when writing to shared resources). The doAppend(Object) method may be called concurrently.

  • Method Details

    • getName

      Get the name of this appender. The name uniquely identifies the appender within its context and is used for configuration and lookup.
      Returns:
      the appender name, or null if not set
    • doAppend

      void doAppend(E event) throws LogbackException
      This is where an appender accomplishes its work: format and deliver the provided event to the appender's destination.

      Implementations should apply any configured filters before outputting the event. Implementations should avoid throwing runtime exceptions; if an error occurs that cannot be handled internally, a LogbackException (or a subtype) may be thrown to indicate a failure during append.

      Parameters:
      event - the event to append; may not be null
      Throws:
      LogbackException - if the append fails in a way that needs to be propagated to the caller
    • setName

      void setName(String name)
      Set the name of this appender. The name is used by other components to identify and reference this appender (for example in configuration or for status messages).
      Parameters:
      name - the new name for this appender; may be null to unset