public class AmqpAppender
extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
A fully-configured AmqpAppender, with every option set to their defaults, would look like this:
<appender name="AMQP" class="org.springframework.amqp.rabbit.logback.AmqpAppender">
<layout>
<pattern><![CDATA[ %d %p %t [%c] - <%m>%n ]]></pattern>
</layout>
<!-- <abbreviation>36</abbreviation --> <!-- no category abbreviation by default -->
<applicationId>AmqpAppenderTest</applicationId>
<routingKeyPattern>%property{applicationId}.%c.%p</routingKeyPattern>
<generateId>true</generateId>
<charset>UTF-8</charset>
<durable>false</durable>
<deliveryMode>NON_PERSISTENT</deliveryMode>
</appender>
Modifier and Type | Class and Description |
---|---|
protected static class |
AmqpAppender.Event
Small helper class to encapsulate a LoggingEvent, its MDC properties, and the number of retries.
|
protected class |
AmqpAppender.EventSender
Helper class to actually send LoggingEvents asynchronously.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
APPLICATION_ID
Key name for the application id (if there is one set via the appender config) in the message properties.
|
static java.lang.String |
CATEGORY_LEVEL
Key name for the logger level name in the message properties
|
static java.lang.String |
CATEGORY_NAME
Key name for the logger category name in the message properties
|
static java.lang.String |
THREAD_NAME
Key name for the thread name in the message properties.
|
Constructor and Description |
---|
AmqpAppender() |
Modifier and Type | Method and Description |
---|---|
protected void |
append(ch.qos.logback.classic.spi.ILoggingEvent event) |
java.lang.String |
getAddresses() |
java.lang.String |
getApplicationId() |
java.lang.String |
getCharset() |
java.lang.String |
getContentEncoding() |
java.lang.String |
getContentType() |
java.lang.String |
getDeliveryMode() |
java.lang.String |
getExchangeName() |
java.lang.String |
getExchangeType() |
java.lang.String |
getHost() |
int |
getMaxSenderRetries() |
java.lang.String |
getPassword() |
int |
getPort() |
int |
getQueuedEventCount()
Return the number of events waiting to be sent.
|
java.lang.String |
getRoutingKeyPattern() |
int |
getSenderPoolSize() |
java.lang.String |
getUsername() |
java.lang.String |
getVirtualHost() |
boolean |
isAutoDelete() |
boolean |
isDeclareExchange() |
boolean |
isDurable() |
boolean |
isGenerateId() |
boolean |
isIncludeCallerData() |
protected void |
maybeDeclareExchange()
Deprecated.
|
protected Message |
postProcessMessageBeforeSend(Message message,
AmqpAppender.Event event)
Subclasses may modify the final message before sending.
|
void |
setAbbreviation(int len) |
void |
setAddresses(java.lang.String addresses) |
void |
setApplicationId(java.lang.String applicationId) |
void |
setAutoDelete(boolean autoDelete) |
void |
setCharset(java.lang.String charset) |
void |
setClientConnectionProperties(java.lang.String clientConnectionProperties)
Set additional client connection properties to be added to the rabbit connection,
with the form
key:value[,key:value]... . |
void |
setContentEncoding(java.lang.String contentEncoding) |
void |
setContentType(java.lang.String contentType) |
void |
setDeclareExchange(boolean declareExchange) |
void |
setDeliveryMode(java.lang.String deliveryMode) |
void |
setDurable(boolean durable) |
void |
setExchangeName(java.lang.String exchangeName) |
void |
setExchangeType(java.lang.String exchangeType) |
void |
setGenerateId(boolean generateId) |
void |
setHost(java.lang.String host) |
void |
setIncludeCallerData(boolean includeCallerData)
If true, the caller data will be available in the target AMQP message.
|
void |
setLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout) |
void |
setMaxSenderRetries(int maxSenderRetries) |
void |
setPassword(java.lang.String password) |
void |
setPort(int port) |
void |
setRoutingKeyPattern(java.lang.String routingKeyPattern) |
void |
setSenderPoolSize(int senderPoolSize) |
protected void |
setUpExchangeDeclaration() |
void |
setUsername(java.lang.String username) |
void |
setVirtualHost(java.lang.String virtualHost) |
void |
start() |
void |
stop() |
protected void |
updateConnectionClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)
Subclasses can override this method to add properties to the connection client
properties.
|
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toString
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
public static final java.lang.String APPLICATION_ID
public static final java.lang.String CATEGORY_NAME
public static final java.lang.String CATEGORY_LEVEL
public static final java.lang.String THREAD_NAME
public void setRoutingKeyPattern(java.lang.String routingKeyPattern)
public java.lang.String getHost()
public void setHost(java.lang.String host)
public int getPort()
public void setPort(int port)
public void setAddresses(java.lang.String addresses)
public java.lang.String getAddresses()
public java.lang.String getVirtualHost()
public void setVirtualHost(java.lang.String virtualHost)
public java.lang.String getUsername()
public void setUsername(java.lang.String username)
public java.lang.String getPassword()
public void setPassword(java.lang.String password)
public java.lang.String getExchangeName()
public void setExchangeName(java.lang.String exchangeName)
public java.lang.String getExchangeType()
public void setExchangeType(java.lang.String exchangeType)
public java.lang.String getRoutingKeyPattern()
public boolean isDeclareExchange()
public void setDeclareExchange(boolean declareExchange)
public java.lang.String getContentType()
public void setContentType(java.lang.String contentType)
public java.lang.String getContentEncoding()
public void setContentEncoding(java.lang.String contentEncoding)
public java.lang.String getApplicationId()
public void setApplicationId(java.lang.String applicationId)
public int getSenderPoolSize()
public void setSenderPoolSize(int senderPoolSize)
public int getMaxSenderRetries()
public void setMaxSenderRetries(int maxSenderRetries)
public boolean isDurable()
public void setDurable(boolean durable)
public java.lang.String getDeliveryMode()
public void setDeliveryMode(java.lang.String deliveryMode)
public boolean isAutoDelete()
public void setAutoDelete(boolean autoDelete)
public boolean isGenerateId()
public void setGenerateId(boolean generateId)
public java.lang.String getCharset()
public void setCharset(java.lang.String charset)
public void setLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout)
public void setAbbreviation(int len)
public int getQueuedEventCount()
public void setClientConnectionProperties(java.lang.String clientConnectionProperties)
key:value[,key:value]...
.clientConnectionProperties
- the properties.public boolean isIncludeCallerData()
public void setIncludeCallerData(boolean includeCallerData)
includeCallerData
- include or on caller dataILoggingEvent.getCallerData()
public void start()
start
in interface ch.qos.logback.core.spi.LifeCycle
start
in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
protected void updateConnectionClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)
clientProperties
- the client properties.public void stop()
stop
in interface ch.qos.logback.core.spi.LifeCycle
stop
in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
protected void append(ch.qos.logback.classic.spi.ILoggingEvent event)
append
in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
@Deprecated protected void maybeDeclareExchange()
setUpExchangeDeclaration()
protected void setUpExchangeDeclaration()
protected Message postProcessMessageBeforeSend(Message message, AmqpAppender.Event event)
message
- The message.event
- The event.