如何在log4j2.xml中配置kafkaappender

lokaqttq  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(740)

我正在尝试配置 Kafka 9 提供 KafkaLog4jAppenderlog4j2.xml .
我的log4j2.xml文件类似于this:-

<?xml version="1.0" encoding="UTF-8"?>
<Configuration packages="org.apache.kafka.log4jappender"
    status="INFO">
    <Appenders>
        <Kafka name="Kafka"  topic="log-test">
            <PatternLayout pattern="%date %message" />
            <Property name="bootstrap.servers">localhost:9092</Property>
        </Kafka>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="Kafka" />
        </Root>
        <Logger name="org.apache.kafka" level="INFO" />
    </Loggers>
</Configuration>

我的日志输出是

2016-03-08 12:14:27,480 ERROR Error processing element Kafka: CLASS_NOT_FOUND
2016-03-08 12:14:27,520 ERROR Unable to locate appender Kafka for logger

如何指定 KafkaLog4jAppender ?
是我使用log4j1的唯一选择吗?

相关问题