log4j 如何避免有关ReflectionsException的警告消息

vnzz0bqm  于 2022-11-06  发布在  其他
关注(0)|答案(1)|浏览(179)

当我启动Confluent时,我如何避免WARN消息显示在日志中(而不将log4j级别设置为ERROR)?我已经在属性文件中设置了plugin.path变量,值为${CONFLUENT_HOME}/share/java/kafka-connect-jdbc(最后用逗号)。我尝试将kafka-connect-jdbc存储库放在类路径中,但没有成功。
以下只是日志文件的一小部分示例:

[2018-07-10 15:40:30,168] INFO Reflections took 1 ms to scan 1 urls, producing 5 keys and 6 values [using 1 cores] (org.reflection
s.Reflections)
[2018-07-10 15:40:30,170] WARN could not get type for name org.jmock.Mockery from any class loader (org.reflections.Reflections)
org.reflections.ReflectionsException: could not get type for name org.jmock.Mockery
        at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:390)
        at org.reflections.Reflections.expandSuperTypes(Reflections.java:381)
        at org.reflections.Reflections.<init>(Reflections.java:126)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader$InternalReflections.<init>(DelegatingClassLoader.java:
365)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanPluginPath(DelegatingClassLoader.java:277)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanUrlsAndAddPlugins(DelegatingClassLoader.java:216)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.registerPlugin(DelegatingClassLoader.java:208)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.initPluginLoader(DelegatingClassLoader.java:177)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.initLoaders(DelegatingClassLoader.java:154)
        at org.apache.kafka.connect.runtime.isolation.Plugins.<init>(Plugins.java:56)
        at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:77)
Caused by: java.lang.ClassNotFoundException: org.jmock.Mockery
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:388)
        ... 10 more

这看起来不会引起任何问题,但读起来会让人感到困惑。你对此有什么建议吗?
先谢谢你,
迪亚哥

6gpjuf90

6gpjuf901#

您可以在log4j配置文件中设置特定包的日志级别:

log4j.logger.org.reflections=ERROR

这帮助了我

相关问题