一次正常的上線,發了幾台docker后,卻發現有的機器打了info.log里面有日志,有的沒有。排查問題開始:
- 第一:確認這台docker是否有流量進來,確認有流量進來。
- 第二:確認這台docker磁盤是否慢了,磁盤沒有滿。
- 第三:確認這台docker日志級別,確認和其他docker一樣配置文件。
- 第四:這個時候就不知道了,病急亂投醫,把部署的包,docker的cpu、內存、tcp、線程數、gc都看了一遍,都是正常的。
- 最后:和同事探討,看catlina啟動的時候有沒有warning日志,結果有所發現。
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/export/Packages/XXXXXX/20190716102533/WEB-INF/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/export/Packages/XXXXXX/20190716102533/WEB-INF/lib/log4j-slf4j-impl-2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
這個時候就很明顯了,兩個包沖突,有有一樣的絕對路徑,導致類加載選擇了其中一個。所以回導致有的docker不打日志。最后排除jar包,重新上線,都正常。
總結:不能只看啟動日志有無startup,有無異常信息,對這些warning日志也要留意。