This is the main purpose of SLF4J (Simple Logging Facade for Java) – a logging abstraction which helps to decouple your application from the underlying logger by allowing it to be plugged in – at runtime. Of course, the flexibility that such an abstraction provides is the main reason to use SLF4J.
Unlike log4j, SLF4J (Simple Logging Facade for Java) is not an implementation of logging framework, it is an abstraction for all those logging frameworks in Java similar to log4J. Therefore, you cannot compare both. However, it is always difficult to prefer one between the two.
The class org. slf4j. ext. EventData is now marked as deprecated in preparation for its removal due to a security vulnerability.
You seem to be missing the following from your pom file.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0.1</version>
</dependency>
Your log4j2 configuration in correct (POM side), but you never say to slf4j where it should write (backend part).
Your should add that to your pom file
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0.1</version>
</dependency>
It is the Log4j 2 SLF4J Binding. According to Log4j 2 SLF4J Binding documentation The Log4j 2 SLF4J Binding allows applications coded to the SLF4J API to use Log4j 2 as the implementation
If it still does not work, you may have an Eclipse problem because Eclipse m2e is known to be weird regarding slf4j. According to this detailed post from SO SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. error a workaround could be to use an external maven to do the build.
Apart from the log4j-slf4j-impl dependency, you also need the slf4j-ext dependency.
See http://logging.apache.org/log4j/2.x/log4j-slf4j-impl/dependencies.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With