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 String |
APPLICATION_ID
Key name for the application id (if there is one set via the appender config) in the message properties.
|
static String |
CATEGORY_LEVEL
Key name for the logger level name in the message properties
|
static String |
CATEGORY_NAME
Key name for the logger category name in the message properties
|
String |
saslConfig
SaslConfig.
|
static 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) |
protected void |
configureRabbitConnectionFactory(RabbitConnectionFactoryBean factoryBean)
Configure the
RabbitConnectionFactoryBean . |
protected BlockingQueue<AmqpAppender.Event> |
createEventQueue()
Subclasses can override this method to inject a custom queue implementation.
|
protected com.rabbitmq.client.ConnectionFactory |
createRabbitConnectionFactory()
Create the
ConnectionFactory . |
String |
getAddresses() |
String |
getApplicationId() |
String |
getCharset() |
String |
getContentEncoding() |
String |
getContentType() |
String |
getDeliveryMode() |
ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> |
getEncoder() |
String |
getExchangeName() |
String |
getExchangeType() |
String |
getHost() |
String |
getKeyStore() |
String |
getKeyStorePassphrase() |
String |
getKeyStoreType() |
int |
getMaxSenderRetries() |
String |
getPassword() |
Integer |
getPort() |
int |
getQueuedEventCount()
Return the number of events waiting to be sent.
|
String |
getRoutingKeyPattern() |
String |
getSaslConfig() |
int |
getSenderPoolSize() |
String |
getSslAlgorithm() |
String |
getSslPropertiesLocation() |
String |
getTrustStore() |
String |
getTrustStorePassphrase() |
String |
getTrustStoreType() |
URI |
getUri() |
String |
getUsername() |
String |
getVirtualHost() |
boolean |
isAddMdcAsHeaders() |
boolean |
isAutoDelete() |
boolean |
isDeclareExchange() |
boolean |
isDurable() |
boolean |
isGenerateId() |
boolean |
isIncludeCallerData() |
boolean |
isUseSsl() |
boolean |
isVerifyHostname()
Return true (default) if TLS hostname verification is enabled.
|
protected Message |
postProcessMessageBeforeSend(Message message,
AmqpAppender.Event event)
Subclasses may modify the final message before sending.
|
protected MessageProperties |
prepareMessageProperties(AmqpAppender.Event event) |
void |
setAbbreviation(int len) |
void |
setAddMdcAsHeaders(boolean addMdcAsHeaders) |
void |
setAddresses(String addresses) |
void |
setApplicationId(String applicationId) |
void |
setAutoDelete(boolean autoDelete) |
void |
setCharset(String charset) |
void |
setClientConnectionProperties(String clientConnectionProperties)
Set additional client connection properties to be added to the rabbit connection,
with the form
key:value[,key:value]... . |
void |
setConnectionName(String connectionName)
Set a name for the connection which will appear on the RabbitMQ Admin UI.
|
void |
setContentEncoding(String contentEncoding) |
void |
setContentType(String contentType) |
void |
setDeclareExchange(boolean declareExchange) |
void |
setDeliveryMode(String deliveryMode) |
void |
setDurable(boolean durable) |
void |
setEncoder(ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> encoder) |
void |
setExchangeName(String exchangeName) |
void |
setExchangeType(String exchangeType) |
void |
setGenerateId(boolean generateId) |
void |
setHost(String host) |
void |
setIncludeCallerData(boolean includeCallerData)
If true, the caller data will be available in the target AMQP message.
|
void |
setKeyStore(String keyStore) |
void |
setKeyStorePassphrase(String keyStorePassphrase) |
void |
setKeyStoreType(String keyStoreType) |
void |
setLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout) |
void |
setMaxSenderRetries(int maxSenderRetries) |
void |
setPassword(String password) |
void |
setPort(Integer port) |
void |
setRoutingKeyPattern(String routingKeyPattern) |
void |
setSaslConfig(String saslConfig)
Set the
SaslConfig . |
void |
setSenderPoolSize(int senderPoolSize) |
void |
setSslAlgorithm(String sslAlgorithm) |
void |
setSslPropertiesLocation(String sslPropertiesLocation) |
void |
setTrustStore(String trustStore) |
void |
setTrustStorePassphrase(String trustStorePassphrase) |
void |
setTrustStoreType(String trustStoreType) |
protected void |
setUpExchangeDeclaration() |
void |
setUri(URI uri) |
void |
setUsername(String username) |
void |
setUseSsl(boolean ssl) |
void |
setVerifyHostname(boolean enable)
Enable server hostname verification for TLS connections.
|
void |
setVirtualHost(String virtualHost) |
void |
start() |
void |
stop() |
protected void |
updateConnectionClientProperties(Map<String,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 String APPLICATION_ID
public static final String CATEGORY_NAME
public static final String CATEGORY_LEVEL
public static final String THREAD_NAME
public String saslConfig
public void setRoutingKeyPattern(String routingKeyPattern)
public URI getUri()
public void setUri(URI uri)
public String getHost()
public void setHost(String host)
public Integer getPort()
public void setPort(Integer port)
public void setAddresses(String addresses)
public String getAddresses()
public String getVirtualHost()
public void setVirtualHost(String virtualHost)
public String getUsername()
public void setUsername(String username)
public String getPassword()
public void setPassword(String password)
public boolean isUseSsl()
public void setUseSsl(boolean ssl)
public void setVerifyHostname(boolean enable)
enable
- false to disable.RabbitConnectionFactoryBean.setEnableHostnameVerification(boolean)
public boolean isVerifyHostname()
public String getSslAlgorithm()
public void setSslAlgorithm(String sslAlgorithm)
public String getSslPropertiesLocation()
public void setSslPropertiesLocation(String sslPropertiesLocation)
public String getKeyStore()
public void setKeyStore(String keyStore)
public String getKeyStorePassphrase()
public void setKeyStorePassphrase(String keyStorePassphrase)
public String getKeyStoreType()
public void setKeyStoreType(String keyStoreType)
public String getTrustStore()
public void setTrustStore(String trustStore)
public String getTrustStorePassphrase()
public void setTrustStorePassphrase(String trustStorePassphrase)
public String getTrustStoreType()
public void setTrustStoreType(String trustStoreType)
public String getSaslConfig()
public void setSaslConfig(String saslConfig)
SaslConfig
.saslConfig
- the saslConfig to setRabbitUtils.stringToSaslConfig(String, ConnectionFactory)
public String getExchangeName()
public void setExchangeName(String exchangeName)
public String getExchangeType()
public void setExchangeType(String exchangeType)
public String getRoutingKeyPattern()
public boolean isDeclareExchange()
public void setDeclareExchange(boolean declareExchange)
public String getContentType()
public void setContentType(String contentType)
public String getContentEncoding()
public void setContentEncoding(String contentEncoding)
public String getApplicationId()
public void setApplicationId(String applicationId)
public int getSenderPoolSize()
public void setSenderPoolSize(int senderPoolSize)
public int getMaxSenderRetries()
public void setMaxSenderRetries(int maxSenderRetries)
public boolean isAddMdcAsHeaders()
public void setAddMdcAsHeaders(boolean addMdcAsHeaders)
public boolean isDurable()
public void setDurable(boolean durable)
public String getDeliveryMode()
public void setDeliveryMode(String deliveryMode)
public boolean isAutoDelete()
public void setAutoDelete(boolean autoDelete)
public boolean isGenerateId()
public void setGenerateId(boolean generateId)
public String getCharset()
public void setCharset(String charset)
public void setLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout)
public ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> getEncoder()
public void setEncoder(ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent> encoder)
public void setAbbreviation(int len)
public int getQueuedEventCount()
public void setConnectionName(String connectionName)
connectionName
- the connection name.public void setClientConnectionProperties(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 com.rabbitmq.client.ConnectionFactory createRabbitConnectionFactory()
ConnectionFactory
.ConnectionFactory
.protected void configureRabbitConnectionFactory(RabbitConnectionFactoryBean factoryBean)
RabbitConnectionFactoryBean
. Sub-classes may override to
customize the configuration of the bean.factoryBean
- the RabbitConnectionFactoryBean
.protected void updateConnectionClientProperties(Map<String,Object> clientProperties)
clientProperties
- the client properties.protected BlockingQueue<AmqpAppender.Event> createEventQueue()
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>
protected void setUpExchangeDeclaration()
protected MessageProperties prepareMessageProperties(AmqpAppender.Event event)
protected Message postProcessMessageBeforeSend(Message message, AmqpAppender.Event event)
message
- The message.event
- The event.