I'm getting the following while setting slf4j on top log4j 2 implementation. Even though I configured log4J2 to be my implementation for slf4j interface..I'm still seeing No SLF4J providers were found. Not sure what I'm missing
Errors in logs
01-10-2022 19:22:46,115 ERROR [stderr] (MSC service thread 1-5) SLF4J: No SLF4J providers were found.
01-10-2022 19:22:46,115 ERROR [stderr] (MSC service thread 1-5) SLF4J: Defaulting to no-operation (NOP) logger implementation
01-10-2022 19:22:46,115 ERROR [stderr] (MSC service thread 1-5) SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
01-10-2022 19:22:46,115 ERROR [stderr] (MSC service thread 1-5) SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
01-10-2022 19:22:46,116 ERROR [stderr] (MSC service thread 1-5) SLF4J: Ignoring binding found at [vfs:/content/abc.war/WEB-INF/lib/log4j-slf4j-impl-2.17.0.jar/org/slf4j/impl/StaticLoggerBinder.class]
01-10-2022 19:22:46,116 ERROR [stderr] (MSC service thread 1-5) SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.
Properties file
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=/sasa.log
log4j.appender.file.Append=true
log4j.appender.file.MaxFileSize=100MB
log4j.appender.file.MaxBackupIndex=5
log4j.appender.file.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n
Java file
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
@Component
public class ABC{
private static final Logger log = LoggerFactory.getLogger(abc.class);
public String getCall(String url) throws Exception {
try {
log.info("getCall url - " + url );
response = new String(get.getResponseBody(), UTFSTR);
log.info(": Response code:"+response);
} catch (Exception e) {
log.error(" getCall - EXCEPTION - " + e.getLocalizedMessage());
throw e;
}
return response;
}
}
pom file configured.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<properties>
<java.version>1.8</java.version>
<slf4j.version>2.0.0-alpha5</slf4j.version>
<log4j2.version>2.17.0</log4j2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>