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.AbstractAppenderA 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 classAmqpAppender.AmqpManagerManager class for the appender.protected static classAmqpAppender.Builderprotected static classAmqpAppender.EventHelper class to encapsulate a LoggingEvent, its MDC properties, and the number of retries.protected classAmqpAppender.EventSenderHelper class to actually send LoggingEvents asynchronously.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPPLICATION_IDKey name for the application id (if there is one set via the appender config) in the message properties.static java.lang.StringCATEGORY_LEVELKey name for the logger level name in the message properties.static java.lang.StringCATEGORY_NAMEKey name for the logger category name in the message properties.static java.lang.StringTHREAD_NAMEKey name for the thread name in the message properties.
-
Constructor Summary
Constructors Constructor Description AmqpAppender(java.lang.String name, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends java.io.Serializable> layout, boolean ignoreExceptions, org.apache.logging.log4j.core.config.Property[] properties, AmqpAppender.AmqpManager manager, java.util.concurrent.BlockingQueue<AmqpAppender.Event> eventQueue)Construct an instance with the provided properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(org.apache.logging.log4j.core.LogEvent event)protected voiddoSend(AmqpAppender.Event event, org.apache.logging.log4j.core.LogEvent logEvent, MessageProperties amqpProps)intgetQueuedEventCount()Return the number of events waiting to be sent.static AmqpAppender.BuildernewBuilder()Create a new builder.protected MessagepostProcessMessageBeforeSend(Message message, AmqpAppender.Event event)Subclasses may modify the final message before sending.protected voidsendEvent(AmqpAppender.Event event, java.util.Map<?,?> properties)protected booleanstop(long timeout, java.util.concurrent.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
-
-
-
-
Field Detail
-
APPLICATION_ID
public static final java.lang.String APPLICATION_ID
Key name for the application id (if there is one set via the appender config) in the message properties.- See Also:
- Constant Field Values
-
CATEGORY_NAME
public static final java.lang.String CATEGORY_NAME
Key name for the logger category name in the message properties.- See Also:
- Constant Field Values
-
CATEGORY_LEVEL
public static final java.lang.String CATEGORY_LEVEL
Key name for the logger level name in the message properties.- See Also:
- Constant Field Values
-
THREAD_NAME
public static final java.lang.String THREAD_NAME
Key name for the thread name in the message properties.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AmqpAppender
public AmqpAppender(java.lang.String name, org.apache.logging.log4j.core.Filter filter, org.apache.logging.log4j.core.Layout<? extends java.io.Serializable> layout, boolean ignoreExceptions, org.apache.logging.log4j.core.config.Property[] properties, AmqpAppender.AmqpManager manager, java.util.concurrent.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 Detail
-
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, java.util.Map<?,?> properties)
-
doSend
protected void doSend(AmqpAppender.Event event, org.apache.logging.log4j.core.LogEvent logEvent, MessageProperties amqpProps)
-
stop
protected boolean stop(long timeout, java.util.concurrent.TimeUnit timeUnit, boolean changeLifeCycleState)- Overrides:
stopin classorg.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.
-
-