由於各類三方庫依賴的log4j實現不一樣,因此可能會出現找到多個log4j實現的警告,可是不影響程序(logback是會影響的),以下:html
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/software/slf4j-log4j12-1.7.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/software/log4j-slf4j-impl-2.4.1.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]
這一般是由於同時包含了slf4j-log4j12和log4j-slf4j-impl,因此去掉slf4j-log4j12,保留log4j-slf4j-impl便可。警告即消失。前者還會致使log4j2的一些PATTERN如%x不生效。spa