Hi,

When trying out the log4j2 Kafka appender, it works ok if all the
log4j2/kafka-client related jars are packaged in the webapp's
WEB-INF/lib, like:

>ls WEB-INF/lib/
jackson-core-2.8.1.jar
log4j-core-2.6.2.jar
lz4-1.3.0.jar
kafka-clients-0.10.0.1.jar
log4j-slf4j-impl-2.6.2.jar
slf4j-api-1.7.21.jar
log4j-api-2.6.2.jar
log4j-web-2.6.2.jar
snappy-java-1.1.2.6.jar


But if the jars are provided in tomcat/lib (for all webapps), and each
webapp will have its own log4j2.xml (as in attached war), then when
launching the webapp, will encounter:

-----
Caused by: java.lang.NullPointerException
        at 
org.apache.kafka.clients.producer.KafkaProducer.close(KafkaProducer.java:658)
        at 
org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:333)
        at 
org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:188)
        at 
org.apache.logging.log4j.core.appender.mom.kafka.DefaultKafkaProducerFactory.newKafkaProducer(DefaultKafkaProducerFactory.java:29)
        at 
org.apache.logging.log4j.core.appender.mom.kafka.KafkaManager.startup(KafkaManager.java:86)
        at 
org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender.start(KafkaAppender.java:96)
        at 
org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:247)
        at 
org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:496)
        at 
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:566)
---------

(full stack trace as in attached catalina.out)


To reproduce the error, simply:
1) build the attached webapp, and deploy the output to tomcat/webapps
2) move the WEB-INF/lib/*.jar to tomcat/lib (make sure WEB-INF/lib is
empty after move)
3) start tomcat

Tested with tomcat 7.0.70

Anyone encounter similar problem? or is this a bug? (log4j2 or
kafka-client bug?)


Thanks,
Bill

Attachment: log4j2-kafka-test.tar.gz
Description: GNU Zip compressed data

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to