Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j.core
Interface Appender

All Superinterfaces:
  LifeCycle

All Known Implementing Classes:
  AbstractAppender, AbstractDatabaseAppender, AbstractOutputStreamAppender, AsyncAppender, ConsoleAppender, FailoverAppender, FileAppender, JdbcAppender, JmsAppender, JpaAppender, MemoryMappedFileAppender, RandomAccessFileAppender, RewriteAppender, RollingFileAppender, RollingRandomAccessFileAppender, RoutingAppender, SmtpAppender, SocketAppender, SyslogAppender

    public interface Appender

extends LifeCycle

Appends `LogEvent`s. An Appender can contain a `Layout` if applicable as well as an `ErrorHandler`. Typical Appender implementations coordinate with an implementation of `AbstractManager` to handle external resources such as streams, connections, and other shared state. As Appenders are plugins, concrete implementations need to be annotated with `Plugin` and need to provide a static factory method annotated with `PluginFactory`.

Most core plugins are written using a related Manager class that handle the actual task of serializing a `LogEvent` to some output location. For instance, many Appenders can take advantage of the `OutputStreamManager` class.

It is recommended that Appenders don't do any heavy lifting since there can be many instances of the class being used at any given time. When resources require locking (e.g., through `FileLock`), it is important to isolate synchronized code to prevent concurrency issues.

Nested Class Summary

Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
`LifeCycle.State`

Method Summary
`void` | `append(LogEvent event)` Logs a LogEvent using whatever logic this Appender wishes to use.
`ErrorHandler` | `getHandler()` Gets the `ErrorHandler` used for handling exceptions.
`Layout<? extends Serializable>` | `getLayout()` Returns the Layout used by this Appender if applicable.
`String` | `getName()` Get the name of this Appender.
`boolean` | `ignoreExceptions()` Some Appenders need to propagate exceptions back to the application.
`void` | `setHandler(ErrorHandler handler)` Sets the `ErrorHandler` used for handling exceptions.

Methods inherited from interface org.apache.logging.log4j.core.LifeCycle
`getState, isStarted, isStopped, start, stop`

Method Detail

### append

    void append(LogEvent event)

  Logs a LogEvent using whatever logic this Appender wishes to use. It is typically recommended to use a bridge pattern not only for the benefits from decoupling an Appender from its implementation, but it is also handy for sharing resources which may require some form of locking.

  Parameters:
    `event` - The LogEvent.

### getName

    String getName()

  Get the name of this Appender.

  Returns:
    name, may be null.

### getLayout

    Layout<? extends Serializable> getLayout()

  Returns the Layout used by this Appender if applicable.

  Returns:
    the Layout for this Appender or `null` if none is configured.

### ignoreExceptions

    boolean ignoreExceptions()

  Some Appenders need to propagate exceptions back to the application. When `ignoreExceptions` is `false` the AppenderControl will allow the exception to percolate.

  Returns:
    `true` if exceptions will be logged but not thrown, `false` otherwise.

### getHandler

    ErrorHandler getHandler()

  Gets the `ErrorHandler` used for handling exceptions.

  Returns:
    the ErrorHandler for handling exceptions.

### setHandler

    void setHandler(ErrorHandler handler)

  Sets the `ErrorHandler` used for handling exceptions.

  Parameters:
    `handler` - the ErrorHandler to use for handling exceptions.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.