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 ClassesModifier and TypeClassDescriptionprotected static classManager class for the appender.protected static classprotected static classHelper class to encapsulate a LoggingEvent, its MDC properties, and the number of retries.protected classHelper 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
FieldsModifier and TypeFieldDescriptionstatic final StringKey name for the application id (if there is one set via the appender config) in the message properties.static final StringKey name for the logger level name in the message properties.static final StringKey name for the logger category name in the message properties.static final StringKey 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, LOGGERFields inherited from interface org.apache.logging.log4j.core.Appender
ELEMENT_TYPE, EMPTY_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionAmqpAppender(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 TypeMethodDescriptionvoidappend(org.apache.logging.log4j.core.LogEvent event) protected voiddoSend(AmqpAppender.Event event, org.apache.logging.log4j.core.LogEvent logEvent, MessageProperties amqpProps) intReturn the number of events waiting to be sent.static AmqpAppender.BuilderCreate a new builder.protected MessagepostProcessMessageBeforeSend(Message message, AmqpAppender.Event event) Subclasses may modify the final message before sending.protected voidsendEvent(AmqpAppender.Event event, Map<?, ?> properties) protected booleanMethods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toStringMethods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, start, stopMethods 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, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.logging.log4j.core.LifeCycle
getState, initialize, isStarted, isStopped, start, stop
-
Field Details
-
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
Key name for the logger category name in the message properties.- See Also:
-
CATEGORY_LEVEL
Key name for the logger level name in the message properties.- See Also:
-
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
Create a new builder.- Returns:
- the builder.
-
append
public void append(org.apache.logging.log4j.core.LogEvent event) -
postProcessMessageBeforeSend
Subclasses may modify the final message before sending.- Parameters:
message- The message.event- The event.- Returns:
- The modified message.
-
sendEvent
-
doSend
protected void doSend(AmqpAppender.Event event, org.apache.logging.log4j.core.LogEvent logEvent, MessageProperties amqpProps) -
stop
- 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.
-