Amqp appender and log4j2
I am trying to use amqpappender from spring amqp project in our project See here:
http://docs.spring.io/spring-amqp/api/org/springframework/amqp/rabbit/log4j/AmqpAppender.html
But we are currently using log4j2 which I suppose the amqp appender does not support. Does anyone know if the amqp appender works with log4j2?
source to share
You can use Spring AMQP v.1.6.0.M1 (or height) and log4j2 xml config .
Application example:
<RabbitMQ name="rabbitmq"
host="localhost" port="5672" user="guest" password="guest" virtualHost="/"
exchange="log4j2Test" exchangeType="fanout" declareExchange="true" durable="true" autoDelete="false"
applicationId="testAppId" routingKeyPattern="%X{applicationId}.%c.%p"
contentType="text/plain" contentEncoding="UTF-8" generateId="true" deliveryMode="NON_PERSISTENT"
charset="UTF-8"
senderPoolSize="3" maxSenderRetries="5">
</RabbitMQ>
source to share
As @Illiahat pointed out, you need to use the latest (not yet released) version, eg 1.6.0.M2
. Current version ( 1.5.5
) does not support log4j 2 , so you get a message RabbitMQ is not recognizable
(it cannot use the class AppenderSkeleton
).
Here's a sample gradle config that will make the log work:
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'
compile 'org.springframework.amqp:spring-rabbit:1.6.0.M2'
}
For the logger, you can use the config from @Illiahat.
source to share