I am trying to use log4j2.xml instad of log4j but I keep getting
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
File is located under src/main/resources
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="WIP">
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %MDC{threadTrackId} %40c{1.} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="warn">
<AppenderRef ref="console"/>
</Root>
<Logger name="com.test" level="debug"/>
<Logger name="org.springframework" level="info"/>
</Loggers>
</Configuration>
I am not sure if the file is being located correctly but the appenders inside it are not read correctly or the file is not being located.
in My pom file I have the following dependencies
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</dependency>
And this is my build section in pom
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.wirecard.wip.db.RecreateDatabase</mainClass>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>
</plugins>
</build>
In my class this is how I initialize my logger
private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);
and my imports are
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
I run my class through maven using this command
mvn -B -f pom.xml exec:java -Dlog4j.configurationFile=log4j2.xml
I also tried
mvn -B -f pom.xml exec:java -Dlog4j.configurationFile=classpath:log4j2.xml
Any help is appreciated