Homewrecker
Homewrecker

Reputation: 1096

Log4j2 configuration location

I am using a Spring boot app with log4j logging enabled. All is well when I run my Spring boot app, I see the log lines in the correct layout. However, when I run a test, I get:

log4j:WARN No appenders could be found for logger (be.delijn.ritsimulator.util.LoadTimeTest). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

I have tried moving the log4j2.xml file to every possible place on the classpath but I cannot seem to resolve this issue. I placed it in the root, under resources etc. I just want to be able to have 1 log4j2.xml file instead of one for main and one for test. Also, I do not want to set it using the system property.

Is this possible? If so, how can I achieve this?

Thanks in advance! Regards

Upvotes: 0

Views: 527

Answers (1)

Remko Popma
Remko Popma

Reputation: 36754

The warning you are seeing is a Log4j 1.2 warning. Somewhere in your classpath there’s a log4j-1.2.x.jar that gets loaded before the Log4j2 jars. This is not good.

Please remove the log4j-1.2.x.jar and add the log4j-1.2-api-2.x.jar: this is a compatibility jar that will route log4j 1.2 API calls to the Log4j2 implementation.

Upvotes: 3

Related Questions