Custom log4j appender in spark executor

前端 未结 3 878
死守一世寂寞
死守一世寂寞 2021-01-02 18:23

I\'m trying to use custom log4j appender inside spark executor, in order to forward all logs to Apache Kafka.

The problem is, log4j is initialized before fatjar\'s c

3条回答
  •  [愿得一人]
    2021-01-02 19:04

    Was facing the same issue , I will post what worked for me, it turns out the KafkaLog4jAppenderclass package name changed in kafka 0.9, here is what I did, added following dependency in pom

    
            org.apache.kafka
            kafka-log4j-appender
            0.9.0.0
        
    

    and changed my log4j.properties from

    log4j.appender.KAFKA=kafka.producer.KafkaLog4jAppender
    

    to

    log4j.appender.KAFKA=org.apache.kafka.log4jappender.KafkaLog4jAppender 
    

提交回复
热议问题