I have a Jetty 9 based application that I inherited. I am trying to put in some logging functionality. I am using slf4j with log4j2. I have added the appropriate jars for this using Maven:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.22</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
Unfortunately, the application keeps failing to find the log4j2.xml file:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
I have placed copies of that XML file in the webapps folder, the main folder under my server, and in the folder where the libraries are -- all places on the web application's classpath. The application still doesn't find it.
Can someone please advise on how I can make this application find the XML file?
Please take a look at the Log4j2 manual page for web applications. By default Log4j2 looks in the WEB-INF folder of your web application.