Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR StatusLogger Log4j2 could not find a logging implementation

I am trying to implement log4j 2 but it keeps throwing the following error.

> ERROR StatusLogger Log4j2 could not find a logging implementation. > Please add log4j-core to the classpath. Using SimpleLogger to log to > the console...   > ERROR LogExample This Will Be Printed On Error  > FATAL LogExample This Will Be Printed On Fatal 

I have tried the solution given on the net. But the don't seem to be working for me.

This is the code that I am trying to run.

package demo;  import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;  public class LogExample {      private static final Logger LOG = LogManager.getLogger(LogExample.class);      public static void main(String[] args) {          LOG.debug("This Will Be Printed On Debug");         LOG.info("This Will Be Printed On Info");         LOG.warn("This Will Be Printed On Warn");         LOG.error("This Will Be Printed On Error");         LOG.fatal("This Will Be Printed On Fatal");         LOG.info("Appending string: {}.", "Hello, World");     }  } 

Project and dependency added in the pom.xml:

enter image description here

enter image description here

Any help is appreciated.

like image 776
Alok Avatar asked Dec 19 '17 07:12

Alok


People also ask

What is root logger in Log4j2?

This concept is known as Logger Hierarchy. Logger Hierarchy is made up of set of LoggerConfig objects with a parent-child relationship. The topmost element in every Logger Hierarchy is the Root Logger. If Log4j2 doesn't find the configuration file, only Root Logger will be used for logging with logging level as ERROR.

What is the latest version of Log4j?

logging. Log4j 2.18. 0 is the latest release of Log4j.

What is Log4j2 selenium?

What is Log4j2? It is a Java-based logging utility. As of this writing, Apache Log4j 2. x is the latest version for Log4j and it provides significant improvements over its predecessor, Log4j 1.


1 Answers

This dependency help to avoid this error from lambda.

<dependency>     <groupId>org.apache.logging.log4j</groupId>     <artifactId>log4j-to-slf4j</artifactId>     <version>2.8.2</version> </dependency> 
like image 192
Sandun Susantha Avatar answered Sep 30 '22 10:09

Sandun Susantha