Class AmqpAppender

java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilterable
org.apache.logging.log4j.core.appender.AbstractAppender
org.springframework.amqp.rabbit.log4j2.AmqpAppender
All Implemented Interfaces:
org.apache.logging.log4j.core.Appender, org.apache.logging.log4j.core.filter.Filterable, org.apache.logging.log4j.core.impl.LocationAware, org.apache.logging.log4j.core.LifeCycle, org.apache.logging.log4j.core.LifeCycle2

@Plugin(name="RabbitMQ", category="Core", elementType="appender", printObject=true) public class AmqpAppender extends org.apache.logging.log4j.core.appender.AbstractAppender
A Log4j 2 appender that publishes logging events to an AMQP Exchange.
Since:
1.6
Author:
Gary Russell, Stephen Oakey, Artem Bilan, Dominique Villard, Nicolas Ristock, Eugene Gusev, Francesco Scipioni
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Manager class for the appender.
    protected static class 
     
    protected static class 
    Helper class to encapsulate a LoggingEvent, its MDC properties, and the number of retries.
    protected class 
    Helper class to actually send LoggingEvents asynchronously.

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

    org.apache.logging.log4j.core.LifeCycle.State
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Key name for the application id (if there is one set via the appender config) in the message properties.
    static final String
    Key name for the logger level name in the message properties.
    static final String
    Key name for the logger category name in the message properties.
    static final String
    Key name for the thread name in the message properties.

    Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

    DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER

    Fields inherited from interface org.apache.logging.log4j.core.Appender

    ELEMENT_TYPE, EMPTY_ARRAY
  • Constructor Summary

    Constructors
    Constructor
    Description
    AmqpAppender(String name, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions, org.apache.logging.log4j.core.config.Property[] properties, AmqpAppender.AmqpManager manager, BlockingQueue<AmqpAppender.Event> eventQueue)
    Construct an instance with the provided properties.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(org.apache.logging.log4j.core.LogEvent event)
     
    protected void
    doSend(AmqpAppender.Event event, org.apache.logging.log4j.core.LogEvent logEvent, MessageProperties amqpProps)
     
    int
    Return the number of events waiting to be sent.
    Create a new builder.
    protected Message
    Subclasses may modify the final message before sending.
    protected void
    sendEvent(AmqpAppender.Event event, Map<?,?> properties)
     
    protected boolean
    stop(long timeout, TimeUnit timeUnit, boolean changeLifeCycleState)
     

    Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender

    error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toString

    Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable

    addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, start, stop

    Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

    equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.logging.log4j.core.LifeCycle

    getState, initialize, isStarted, isStopped, start, stop
  • Field Details

    • APPLICATION_ID

      public static final String APPLICATION_ID
      Key name for the application id (if there is one set via the appender config) in the message properties.
      See Also:
    • CATEGORY_NAME

      public static final String CATEGORY_NAME
      Key name for the logger category name in the message properties.
      See Also:
    • CATEGORY_LEVEL

      public static final String CATEGORY_LEVEL
      Key name for the logger level name in the message properties.
      See Also:
    • THREAD_NAME

      public static final String THREAD_NAME
      Key name for the thread name in the message properties.
      See Also:
  • Constructor Details

    • AmqpAppender

      public AmqpAppender(String name, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions, org.apache.logging.log4j.core.config.Property[] properties, AmqpAppender.AmqpManager manager, BlockingQueue<AmqpAppender.Event> eventQueue)
      Construct an instance with the provided properties.
      Parameters:
      name - the name.
      filter - the filter.
      layout - the layout.
      ignoreExceptions - true to ignore exceptions.
      manager - the manager.
      eventQueue - the event queue.
      properties - the properties.
  • Method Details

    • newBuilder

      @PluginBuilderFactory public static AmqpAppender.Builder newBuilder()
      Create a new builder.
      Returns:
      the builder.
    • append

      public void append(org.apache.logging.log4j.core.LogEvent event)
    • postProcessMessageBeforeSend

      protected Message postProcessMessageBeforeSend(Message message, AmqpAppender.Event event)
      Subclasses may modify the final message before sending.
      Parameters:
      message - The message.
      event - The event.
      Returns:
      The modified message.
    • sendEvent

      protected void sendEvent(AmqpAppender.Event event, Map<?,?> properties)
    • doSend

      protected void doSend(AmqpAppender.Event event, org.apache.logging.log4j.core.LogEvent logEvent, MessageProperties amqpProps)
    • stop

      protected boolean stop(long timeout, TimeUnit timeUnit, boolean changeLifeCycleState)
      Overrides:
      stop in class org.apache.logging.log4j.core.filter.AbstractFilterable
    • getQueuedEventCount

      public int getQueuedEventCount()
      Return the number of events waiting to be sent.
      Returns:
      the number of events waiting to be sent.