Log4j is not accessible in eclipse

31 Views Asked by At

I'm new to java. Need to use log4j in the project. I have added the class path for both core and api files of log4j. But when i try to import the file into my project, i'm getting an error saying "The type org.apache.logging.log4j.Logger is not accessible".I Need your help to fix this issue. The error and the classpath screenshots

Since i'm new to development and IDE. I'm not sure about how to check the IDE settings.

1

There are 1 best solutions below

0
Piotr P. Karwasz On BEST ANSWER

You chose a steep slope to learn Java: you have a module-info.java module descriptor in it. The Java Platform Module System was introduced in Java 9 (cf. tutorial), but is far from being widespread.

You have two solutions:

  • remove the module-info.java file from your project,
  • or move both libraries to the "Modulepath" and add:
    requires org.apache.logging.log4j;
    
    to your module-info.java file (which is the log4j-api module, the log4j-core module is runtime-only and you shouldn't access it in code).