Why Log4j thinks my project is running in a Servlet environment

I have a simple java project (maven). What creates the jar, and we perform the main method. But when I run mvn clean testin the project, I get the log line from log4j saying

INFO Log4j appears to be running in a Servlet environment, but there no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.

The file log4j2.xmlis located at src/main/resources/log4j2.xml.

Any ideas on what's going on?

+4
source share
2 answers

If you have a servlet-apiJar in your classpath, Log4j will think that you are working in a Servlet container. In particular, he is looking for availability javax.servlet.ServletContext. If your application is not running in the Servlet container, you really will not need this Jar.

+3
source

, , JUnit , :

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-web</artifactId>
    <version>2.6.2</version>
    <scope>test</scope>
</dependency>

, , - .

, "" ​​ "info", log4j -.

0

All Articles