gpt4 book ai didi

java - kafka-log4j-appender 0.9.0.1 省略了错误的可抛出信息

转载 作者:行者123 更新时间:2023-12-02 03:45:50 25 4
gpt4 key购买 nike

看起来 kafka-log4j-appender 0.9.0.1 在向 Kafka 发送消息时省略了可抛出信息。我正在使用以下配置:

log4j.rootLogger=INFO, stdout
log4j.logger.kafka=INFO, stdout
log4j.logger.com.doublev=INFO, KAFKA

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.KAFKA=org.apache.kafka.log4jappender.KafkaLog4jAppender
log4j.appender.KAFKA.layout=org.apache.log4j.PatternLayout
log4j.appender.KAFKA.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.KAFKA.brokerList=localhost:9092
log4j.appender.KAFKA.topic=logs
log4j.appender.KAFKA.syncSend=false

控制台中的示例输出:

ERROR [main] (App.java:21) - / by zero
java.lang.ArithmeticException: / by zero
at com.doublev.sls.test.App.main(App.java:19)

在 Kafka 端它收到:

ERROR [main] (App.java:21) - / by zero

最佳答案

Kafka 附加程序有相当广泛的设置。请参阅以下内容:

log4j.appender.KAFKA.compressionType=none
log4j.appender.KAFKA.requiredNumAcks=0
log4j.appender.KAFKA.syncSend=true //did you try false here?
log4j.appender.KAFKA.Serializer=kafka.producer.DefaultStringEncoder

也请使用

log4j.appender.KAFKA.layout=org.apache.log4j.EnhancedPatternLayout

根据log4j java doc

The PatternLayout does not handle the throwable contained within LoggingEvents.

关于java - kafka-log4j-appender 0.9.0.1 省略了错误的可抛出信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36312158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com