我的目标是将kafka-connect中的日志格式做成json,但以下日志消息始终不是json,无法禁用:
Feb 10, 2020 4:36:03 PM org.glassfish.jersey.internal.inject.Providers checkProviderRuntime
WARNING: A provider org.apache.kafka.connect.runtime.rest.resources.RootResource registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider org.apache.kafka.connect.runtime.rest.resources.RootResource will be ignored.
Feb 10, 2020 4:36:03 PM org.glassfish.jersey.internal.inject.Providers checkProviderRuntime
WARNING: A provider org.apache.kafka.connect.runtime.rest.resources.ConnectorsResource registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider org.apache.kafka.connect.runtime.rest.resources.ConnectorsResource will be ignored.
Feb 10, 2020 4:36:03 PM org.glassfish.jersey.internal.inject.Providers checkProviderRuntime
WARNING: A provider org.apache.kafka.connect.runtime.rest.resources.ConnectorPluginsResource registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider org.apache.kafka.connect.runtime.rest.resources.ConnectorPluginsResource will be ignored.
Feb 10, 2020 4:36:05 PM org.glassfish.jersey.internal.Errors logErrors
WARNING: The following warnings have been detected: WARNING: The (sub)resource method createConnector in org.apache.kafka.connect.runtime.rest.resources.ConnectorsResource contains empty path annotation.
WARNING: The (sub)resource method listConnectors in org.apache.kafka.connect.runtime.rest.resources.ConnectorsResource contains empty path annotation.
WARNING: The (sub)resource method listConnectorPlugins in org.apache.kafka.connect.runtime.rest.resources.ConnectorPluginsResource contains empty path annotation.
WARNING: The (sub)resource method serverInfo in org.apache.kafka.connect.runtime.rest.resources.RootResource contains empty path annotation.
字符串
我知道这些都是警告,所以我的目标是要么避免这些警告出现,要么用json实现。但也不工作。
我尝试了以下设置:
<logger name="org.glassfish.jersey.internal.inject.Providers" additivity="true" level="ERROR" />
型
这些日志消息仍然显示。有什么建议吗?
我可以使用logback或log4j。我目前使用logback,但使用log4j不是问题。
更新
我切换到log4j
log4j.rootCategory=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=net.logstash.log4j.JSONEventLayoutV1
log4j.logger.org.reflections=ERROR
log4j.logger.org.apache.kafka=INFO
log4j.logger.org.apache.kafka.connect.runtime.rest=ERROR
log4j.logger.org.apache.kafka.clients.consumer.ConsumerConfig=ERROR
log4j.logger.org.apache.kafka.clients.producer.ProducerConfig=ERROR
log4j.logger.org.apache.kafka.clients.admin.AdminClientConfig=ERROR
型
日志是json格式的,除了WARNINGS仍然存在,即使我设置了log4j.logger.org.glassfish.jersey.internal.inject.Provider=ERROR
3条答案
按热度按时间5lhxktic1#
该日志消息是使用JDK内置日志记录器(java.util.logging)记录的,而不是SLF 4J或log4J:
https://github.com/jersey/jersey/blob/faa809da43538ce31076b50f969b4bd64caa5ac9/core-common/src/main/java/org/glassfish/jersey/internal/inject/Providers.java#L514
您需要编辑默认的JVM logging.properties文件或创建一个自定义文件并使用JVM选项 -Djava.util.logging.config.file 引用它,以便将 org.glassfish.jersey.internal 的日志级别设置为SEVERE。
Java中的日志是复杂和混乱的。您最终不得不了解所有不同的日志记录产品,并且它们通常混合在同一个项目中。
示例logging.properties文件:
字符串
xxe27gdn2#
即使我设置log4j.logger.org.glassfish.jersey.internal.inject.Provider=ERROR,警告仍然存在
类是Providers,带有% s
我个人建议
字符串
cwdobuhd3#
正如Ryan所评论的,要抑制或更改这些日志,必须修改
logging.properties
文件。如果要修改Kafka Connect Docker镜像中的默认文件,则位于/usr/lib/jvm/jre/conf/logging.properties