Reputation: 1512
So,
once again im totally stuck with this error.. I've read few threads about the issue but cant fix it..
SLF4J: Found binding in [jar:file:/home/me/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/me/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
mvn dependency:tree gives following:
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.3.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.0.3.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.0.3.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.3.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.3.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
For what i understand one instance is under starter-data-jpa and in the folder .m2/ch/qos
but i cant delete that folder or the app wont start.
i cant seem to exclude it either.
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
After exclusion i run mvn clean
and re-import all the dependecies but it still wont start.
And when i delete the whole
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
section, it now resides under [INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.3.RELEASE:compile
according to mvn dependency:tree
and app still wont start, same error.
So how do i get rid of this thing?
I have no idea how this happend. i have not added or removed anything in pom for weeks.
Upvotes: 0
Views: 9720
Reputation: 623
This problem exists from a long time. The best way to deal with this is to follow the steps:
Look for maven dependencies. Search for log4j-slf4j. This library can be from multiple dependencies. I didn't want to remove spring-boot-starter-logging as it effects regular pretty spring logs. How to get a dependency tree for an artifact?.
mvn dependency:tree
Exclude the dependency. You must be able to find one or more dependencies which has the same library. I had slf4j-log4j12 only in kafka-avro-serializer so I excluded from it. If your mvn dependency tree shows more thatn one make sure you exclude from all.
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-avro-serializer</artifactId>
<version>4.0.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
Upvotes: 2
Reputation: 1512
Decided to exclude all the logging framework so there wont be anymore unwanted loggers anywhere... it works
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
Upvotes: 1