public class AmqpAppender
extends org.apache.log4j.AppenderSkeleton
A fully-configured AmqpAppender, with every option set to their defaults, would look like this:
log4j.appender.amqp=org.springframework.amqp.log4j.AmqpAppender #------------------------------- ## Connection settings #------------------------------- log4j.appender.amqp.host=localhost log4j.appender.amqp.port=5672 log4j.appender.amqp.username=guest log4j.appender.amqp.password=guest log4j.appender.amqp.virtualHost=/ #------------------------------- ## Exchange name and type #------------------------------- log4j.appender.amqp.exchangeName=logs log4j.appender.amqp.exchangeType=topic #------------------------------- ## Log4J-format pattern to use to create a routing key. ## The application id is available as %X{applicationId}. #------------------------------- log4j.appender.amqp.routingKeyPattern=%c.%p #------------------------------- ## Whether or not to declare this configured exchange #------------------------------- log4j.appender.amqp.declareExchange=false #------------------------------- ## Flags to use when declaring the exchange #------------------------------- log4j.appender.amqp.durable=true log4j.appender.amqp.autoDelete=false #------------------------------- ## Message properties #------------------------------- log4j.appender.amqp.contentType=text/plain log4j.appender.amqp.contentEncoding=null log4j.appender.amqp.generateId=false log4j.appender.amqp.charset=null #------------------------------- ## Sender configuration #------------------------------- log4j.appender.amqp.senderPoolSize=2 log4j.appender.amqp.maxSenderRetries=30 log4j.appender.amqp.applicationId=null #------------------------------- ## Standard Log4J stuff #------------------------------- log4j.appender.amqp.layout=org.apache.log4j.PatternLayout log4j.appender.amqp.layout.ConversionPattern=%d %p %t [%c] - <%m>%n
Modifier and Type | Class and Description |
---|---|
protected 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
|
Constructor and Description |
---|
AmqpAppender() |
Modifier and Type | Method and Description |
---|---|
void |
append(org.apache.log4j.spi.LoggingEvent event) |
void |
close() |
String |
getApplicationId() |
String |
getCharset() |
String |
getContentEncoding() |
String |
getContentType() |
String |
getExchangeName() |
String |
getExchangeType() |
String |
getHost() |
int |
getMaxSenderRetries() |
String |
getPassword() |
int |
getPort() |
String |
getRoutingKeyPattern() |
int |
getSenderPoolSize() |
String |
getUsername() |
String |
getVirtualHost() |
boolean |
isAutoDelete() |
boolean |
isDeclareExchange() |
boolean |
isDurable() |
boolean |
isGenerateId() |
protected void |
maybeDeclareExchange()
Maybe declare the exchange.
|
boolean |
requiresLayout() |
void |
setApplicationId(String applicationId) |
void |
setAutoDelete(boolean autoDelete) |
void |
setCharset(String charset) |
void |
setContentEncoding(String contentEncoding) |
void |
setContentType(String contentType) |
void |
setDeclareExchange(boolean declareExchange) |
void |
setDurable(boolean durable) |
void |
setExchangeName(String exchangeName) |
void |
setExchangeType(String exchangeType) |
void |
setGenerateId(boolean generateId) |
void |
setHost(String host) |
void |
setMaxSenderRetries(int maxSenderRetries) |
void |
setPassword(String password) |
void |
setPort(int port) |
void |
setRoutingKeyPattern(String routingKeyPattern) |
void |
setSenderPoolSize(int senderPoolSize) |
void |
setUsername(String username) |
void |
setVirtualHost(String virtualHost) |
protected void |
startSenders()
Submit the required number of senders into the pool.
|
public static final String APPLICATION_ID
public static final String CATEGORY_NAME
public static final String CATEGORY_LEVEL
public String getHost()
public void setHost(String host)
public int getPort()
public void setPort(int port)
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 String getExchangeName()
public void setExchangeName(String exchangeName)
public String getExchangeType()
public void setExchangeType(String exchangeType)
public String getRoutingKeyPattern()
public void setRoutingKeyPattern(String routingKeyPattern)
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 isDurable()
public void setDurable(boolean durable)
public boolean isAutoDelete()
public void setAutoDelete(boolean autoDelete)
public boolean isGenerateId()
public void setGenerateId(boolean generateId)
public String getCharset()
public void setCharset(String charset)
protected void startSenders()
protected void maybeDeclareExchange()
public void append(org.apache.log4j.spi.LoggingEvent event)
append
in class org.apache.log4j.AppenderSkeleton
public void close()
public boolean requiresLayout()