因为各种三方库依赖的log4j实现不同,所以可能会出现找到多个log4j实现的警告,但是不影响程序(logback是会影响的),如下:
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即可
使用SLF4j+Log4j2时使用的桥接包是log4j-slf4j-impl, 当有多个SLF4j的桥接包时,一定要排除不需要的包