Gangmax Blog

Use External log4j2 Configuration File

When running a Java application, if I want to use an external “log4j2” configuration file instead of the default one inside the jar file, how can I do?

The answer below comes from the posts here and here.

1
java -Dlog4j2.configurationFile=file:/home/auser/code/sample-project/src/test/resources/log4j2-test.xml -jar sample-project-1.0.0-all.jar

Comments