Log4J Error: “log4j:WARN No appenders could be found for logger”

I recently got these errors when working on a Java web app:

[ERROR] log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
[ERROR] log4j:WARN Please initialize the log4j system properly.

My issue was that my project utilized Log4J2 and a dependency in my pom.xml utilized Log4J. To find which dependency is to blame, comb through the output of the mvn dependency:tree command.

There are a few solutions that could be utilized including changing the dependency to Log4J2, adding a log4j.properties file to the project outputting error messages, or adding a log4j.properties file to the dependency. Adding a log4j.properties file to the dependency made most sense in my case; I didn’t want every project that refers to the dependency to have to define and populate a log4j.properties file. We will go over adding a log4j.properties file to the dependency itself.

Navigate to the resources directory of the offending dependency and create an empty file named log4j.properties. Populating this file with any valid configuration should get rid of the appender error. Remember, this artifact must be published and then referred to the original project.

That’s it! Your error should be fixed!

Navigate to dependency that utilizes log4j and define and populate a log4j.properties file in the resources directory.

Leave a Reply

Your email address will not be published. Required fields are marked *