无法使用log4j.properties从spark应用程序禁用Kafka日志

mrfwxfqh  于 2023-06-21  发布在  Apache
关注(0)|答案(1)|浏览(140)

我想在kubernetes中禁用Kafka日志。我已经在Spark应用程序中设置了log4j属性下面的条目

log4j.rootLogger=INFO, stdout, stderr, kafkaAppender
  log4j.logger.Client=INFO, stdout, stderr
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  log4j.appender.stdout.Threshold=INFO
  log4j.appender.stdout.Target=System.out
  log4j.appender.stdout.immediateFlush=true
  log4j.logger.kafka=ERROR, WARN
  log4j.logger.org.apache.kafka=ERROR, WARN
  log4j.logger.org.apache.kafka.clients.producer.KafkaProducer=ERROR, WARN
  log4j.logger.org.apache.kafka.streams=ERROR, WARN
  log4j.additivity.org.apache.kafka.streams=false
  log4j.logger.org.apache.kafka.clients.consumer=ERROR, WARN
  log4j.logger.org.apache.kafka.clients.producer=ERROR, WARN
  log4j.logger.org.apache.kafka.clients.consumer.internals.SubscriptionState=ERROR, WARN

我仍然在kubernetes driver pod中看到如下所示的INFO日志

> INFO SubscriptionState: [Consumer... 
> INFO SubscriptionState:[Producer...

我是否在中添加了正确的配置

vqlkdk9b

vqlkdk9b1#

official kafka github repo包含用于配置Kafka和log4j的可用选项列表。从您给出的属性列表中,我们可以看到仍然存在一些Kafka配置。如果你想完全删除Kafka日志,请注解它们或使用下面给出的OFF选项。

log4j.logger.Client=INFO, stdout, stderr
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.immediateFlush=true log4j.logger.kafka=OFF
log4j.logger.org.apache.kafka=OFF
log4j.logger.org.apache.kafka.clients.producer.KafkaProducer=OFF
log4j.logger.org.apache.kafka.streams=OFF
log4j.additivity.org.apache.kafka.streams=false
log4j.logger.org.apache.kafka.clients.consumer=OFF
log4j.logger.org.apache.kafka.clients.producer=OFF
log4j.logger.org.apache.kafka.clients.consumer.internals.SubscriptionState=OFF

如果您只是想从log4j中删除Kafka应用程序的信息级别日志,请将下面的属性设置为更高级别,然后重新启动相应的服务以应用这些设置

log4j.logger.org.apache.kafka=Error

按照url了解有关Kafka和log4j集成的详细信息。

相关问题