I am trying to use log4j in a project I am executing with the exec-maven-plugin. I have tried placing the file in the following locations:
$PROJECT_HOME
$PROJECT_HOME/src/main/resources
$PROJECT_HOME/target
$PROJECT_HOME/target/classes
For all locations of the file, I am getting the following message when executing the code:
log4j:WARN No appenders could be found for logger (mypacakge.MyClass).
log4j:WARN Please initialize the log4j system properly.
Where should the log4j.properties
file be located?
exec-maven-plugin config:
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<mainClass>mypackage.Main</mainClass>
</configuration>
</plugin>
...
The file is named log4j. properties and is located in the $DGRAPH_HOME/dgraph-hdfs-agent/lib directory. The file defines the ROLLINGFILE appenders for the root logger and also sets the log level for the file. The level of the root logger is defined as INFO and attaches the ROLLINGFILE appender to it.
You have two choices:
./src/main/resources/log4j.xml
$ mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=com.lei.java.sample.Test -Dlog4j.configuration=file:./log4j.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With