我使用 Apache Beam vs Kafka Clients 来处理我的数据,但是 Kafka Clients 库会产生很多消息,所以它们确实在堆栈跟踪中很混乱,我该如何更改这个包的日志级别?
依赖版本:slf4jVersion=1.7.29
,apacheBeamVersion=2.18.0
我已经添加了一个文件log4j.properties
,src/main/resources/
内容如下,但它似乎不起作用
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.logger.org.apache.kafka.clients.consumer.internals=ERROR
构建.gradle
dependencies {
implementation "org.apache.beam:beam-sdks-java-core:${apacheBeamVersion}"
implementation "org.apache.beam:beam-runners-google-cloud-dataflow-java:${apacheBeamVersion}"
implementation "org.apache.beam:beam-sdks-java-io-google-cloud-platform:${apacheBeamVersion}"
implementation "org.apache.beam:beam-sdks-java-io-kafka:${apacheBeamVersion}"
runtimeOnly "org.slf4j:slf4j-jdk14:${slf4jVersion}"
...
}
我想在我的日志中避免的日志消息:
INFO: [Consumer clientId=consumer-3, groupId=Reader-0_offset_consumer_1776081144_custom-group-group-local] Seeking to LATEST offset of partition custom-group-0
Mar 16, 2020 1:55:34 PM org.apache.kafka.clients.consumer.internals.SubscriptionState maybeSeekUnvalidated
INFO: [Consumer clientId=consumer-3, groupId=Reader-0_offset_consumer_1776081144_custom-group-group-local] Resetting offset for partition custom-group-0 to offset 9347.
Mar 16, 2020 1:55:35 PM org.apache.kafka.clients.consumer.internals.SubscriptionState lambda$requestOffsetReset$3
INFO: [Consumer clientId=consumer-3, groupId=Reader-0_offset_consumer_1776081144_custom-group-group-local] Seeking to LATEST offset of partition custom-group-0
Mar 16, 2020 1:55:35 PM org.apache.kafka.clients.consumer.internals.SubscriptionState maybeSeekUnvalidated
INFO: [Consumer clientId=consumer-3, groupId=Reader-0_offset_consumer_1776081144_custom-group-group-local] Resetting offset for partition custom-group-0 to offset 9347.
Mar 16, 2020 1:55:36 PM org.apache.kafka.clients.consumer.internals.SubscriptionState lambda$requestOffsetReset$3
INFO: [Consumer clientId=consumer-3, groupId=Reader-0_offset_consumer_1776081144_custom-group-group-local] Seeking to LATEST offset of partition custom-group-0
Mar 16, 2020 1:55:36 PM org.apache.kafka.clients.consumer.internals.SubscriptionState maybeSeekUnvalidated
INFO: [Consumer clientId=consumer-3, groupId=Reader-0_offset_consumer_1776081144_custom-group-group-local] Resetting offset for partition custom-group-0 to offset 9347.