Issue
Im trying to include log4j2 in my springboot project, but i get the following error.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/mn/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.10.0/8e4e0a30736175e31c7f714d95032c1734cfbdea/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/mn/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.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.apache.logging.slf4j.Log4jLoggerFactory]
My gradle file looks like this:
dependencies {
compile('org.springframework.boot:spring-boot-starter') {
exclude module:'spring-boot-starter-logging'
}
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-log4j2')
compile('org.springframework:spring-oxm')
compile('org.codehaus.castor:castor-xml:1.3.3')
compile('org.apache.commons:commons-collections4:4.1')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
Im pretty sure the Spring-boot-starter is the one implementing the logging, which is why i tried excluding that, but it doesnt work. Am i excluding it wrong, or the wrong thing?
Solution
Fixed this. It was cause because both spring-boot-starter-web and spring-boot-starter-security also uses the standart logging, so it had to be excluded from all of them
Answered By – Mike Nor
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0