使用Storm配置登录

时间:2019-01-04 22:11:30

标签: maven logback apache-storm maven-shade-plugin

我有一个Storm项目,使用logback.xml添加了一些自定义的logback配置(添加了将日志写入索引的配置)。当我构建jar并将其部署到集群上时,由于类StaticLoggerBinder.class同时存在于jar和Storm自己的依赖项列表中,因此我得到了此类SLF4J: Found binding in [jar:file:/usr/lib/storm/apache-storm-1.2.2/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/app/test/test-storm-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class] 的多个绑定错误。下面是错误

lib

这将导致我的所有自定义配置都无法使用。 当我从Storm的logback.xml文件夹中删除有冲突的jar时,我的22:05:13,818 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/app/test/test-storm-0.0.55-SNAPSHOT-jar-with-dependencies.jar!/logback.xml] 22:05:13,839 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@19bb089b - URL [jar:file:/app/test/test-storm-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/logback.xml] is not of type file 22:05:14,094 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 22:05:14,097 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE] 22:05:14,102 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 22:05:14,125 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.splunk.logging.HttpEventCollectorLogbackAppender] 22:05:14,126 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [SPLUNK] 22:05:14,132 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.test] to INFO 22:05:14,132 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.test] to false 22:05:14,132 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [SPLUNK] to Logger[com.test] 22:05:14,133 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[com.test] 22:05:14,133 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO 22:05:14,133 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT] 22:05:14,133 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 配置会得到反映,并且我的日志会毫无问题地写入索引。在部署拓扑时,在开始时我还会看到这些日志,其中显示了我添加的配置

maven-shade-plugin

但是,我不想走这条路线,因为它无法维护,因此我决定使用org.slf4j.implorg.shaded.slf4j.impl移至logback.xml。现在,当我部署拓扑时,不再有多个绑定,但是我的{{1}}不被接受,并且我的配置都没有得到反映,也看不到以上消息。它可能回落到使用其他记录器。

在部署拓扑时如何反映我的配置?请帮忙。 (风暴版本1.2.2)

1 个答案:

答案 0 :(得分:0)

几年前,Storm从Logback切换到Log4j2。您可以通过storm / log4j2 / worker.xml和storm / log4j2 / cluster.xml文件配置Log4j2。前者为您的拓扑以及工作JVM配置日志记录。

您应该从胖子中排除登录。

也请参见此答案https://stackoverflow.com/a/50229035/8845188