Log4j2 Java unable to import org.apache.logging.log4j.core

I am trying to use the Log4j2 API to write a Converter plugin with version 2.8.2 but am unable to import org.apache.logging.log4j.core to import the following:

org.apache.logging.log4j.core.LogEvent, org.apache.logging.log4j.core.config.plugins.Plugin, org.apache.logging.log4j.core.pattern.*

I have added the maven dependencies as and this works fine with Log4j 2.8.1

<dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.8.2</version>
</dependency>
<dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.8.2</version>
</dependency>

Update: log4j-core-2.8.2.jar content

enter image description here

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation=" "> <modelVersion>4.0.0</modelVersion> <groupId>com.andrew_flower.test</groupId> <artifactId>logtest1</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.8.2</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.8.2</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.9</version> <scope>test</scope> </dependency> </dependencies> <repositories> <repository> <id>central</id> <url> </repository> <repository> <id>apache.snapshots</id> <name>Apache Release Distribution Repository</name> <url> </url> </repository> </repositories>
</project>
8

1 Answer

I believe you experiencing weird configuration problems with maven local repository, because your log4j-core.jar content is from log4j-api.jar
I copied your pom.xml to my environment just for test, it works fine.my configTry navigate to log4j folder on your pc under .m2 repository (yourUser/.m2/repository/org/apache/logging/log4j)
and delete all folders, then go to you project and execute mvn install to import all libraries one more time, i hope it will help.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like