问题产生的现象是:storm任务启动后无日志输出(指的是$STORM_HOME/logs下无对应日志)
控制台输出如下:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/vipshop/platform/storm-0.9.0.1/lib/logback-classic-1.0.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/dcli/workspace/run-jobs/vip_storm_trfcstat-1.0-SNAPSHOT-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. Running: java -client -Dstorm.options=xxxx SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/vipshop/platform/storm-0.9.0.1/lib/logback-classic-1.0.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/dcli/workspace/run-jobs/vip_storm_trfcstat-1.0-SNAPSHOT-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. run remote mode xxxx
根据SLF4J给出的warning信息,很容易定位问题是绑定了多个SLF4J对象
可是官网也说了,如果绑定多个的话,org/slf4j/impl/StaticLoggerBinder会挑选一个进行绑定为什么还会出错呢?
刚开始是先解决问题,在我的项目中除了storm的项目外其他使用日志服务都加上了:
复制代码
1
2
3
4
5
6
7
8<exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion>
加上后日志可以正常打印
但是控制台输出还是有 mutilple bindings的日志
------------------------------------------------------
后来得空后,为了搞清楚为什么打不出日志,所以看了下当时分支的dependency tree
无法打印的branch 名称:debug-log
稍微整理了下,大概是这样
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15dpcommon +hbase log4j:log4j:jar:1.2.17:compile org.slf4j:slf4j-log4j12:jar:1.4.3:compile storm_core +kafka org.slf4j:slf4j-simple:jar:1.6.4:compile storm +storm +- org.slf4j:log4j-over-slf4j:jar:1.6.6:provided +- org.slf4j:slf4j-api:jar:1.6.5:provided (scope not updated to compile) +- ch.qos.logback:logback-classic:jar:1.0.6:provided | - ch.qos.logback:logback-core:jar:1.0.6:provided
因为加入CLASSPATH的还有$STORM_HOME/lib(使用storm版本0.9.0.1),发现如下文件
log4j-over-slf4j-1.6.6.jar
slf4j-api-1.6.5.jar
slf4j-api-1.6.5.jar
同时 logback-classic-1.0.6.jar也引用了slf4j的依赖
看到这里,得出:应该是引用依赖的版本出现冲突,可能是随机选择的版本是低版本,无对应的接口,所以日志无法打印
看到这里,得出:应该是引用依赖的版本出现冲突,可能是随机选择的版本是低版本,无对应的接口,所以日志无法打印
同时,根据依赖树增加了exclusion
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16<exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> </exclusion>
这样程序运行时无warning出现。
最后
以上就是积极毛巾最近收集整理的关于一次调试无法打印日志问题经历的全部内容,更多相关一次调试无法打印日志问题经历内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复