I have used SLF4J logging to print all the logs. I am using the latest version of org.slf4j.
implementation 'org.slf4j:slf4j-api:2.0.0-alpha1'
implementation 'org.slf4j:log4j-over-slf4j:2.0.0-alpha1'
But I'm getting the following error and also no logs are being printed.
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
SLF4J: Ignoring binding found at [jar:file:/home/user/.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#ignoredBindings for an explanation.
The logs are working fine with the older version (1.7.25). Is there anything needs to be added or configured on the project so that these logs can be printed
As the name already indicates slf4j-log4j12 contains log4j v1. 2.
Spring Boot makes use of Apache Commons' Logging for its system logs by default. Additionally, by default you can use any of the logging frameworks under the SLF4J API such as Logback (which is the default), Log4J2, and Java Util Logging in Spring Boot.
SLF4J supports popular logging frameworks, namely log4j, java. util. logging, Simple logging and NOP. The logback project supports SLF4J natively.
Simple Logging Facade for Java (SLF4J) provides a Java logging API by means of a simple facade pattern. The underlying logging backend is determined at runtime by adding the desired binding to the classpath and may be the standard Sun Java logging package java.
It will print the messages adding slf4j-log4j12 instead of slf4j-api
Remove the following
implementation 'org.slf4j:slf4j-api:2.0.0-alpha1'
implementation 'org.slf4j:log4j-over-slf4j:2.0.0-alpha1'
Add
implementation group: 'org.slf4j', name: 'slf4j-log4j12', version: '+'
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