As logging-tool I am using Log4j2 and this is invoked by using a system property (/VM argument), using:
-Dlog4j.configurationFile=./config/log4j2_config.xml
For compiling my projects I am using Maven and to create exe-files Launch4j (Plugin: com.akathist.maven.plugins.launch4j).
The plugin definition in my pom.xml looks like that:
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<cmdLine>./config/MyConfig.xml</cmdLine>
<opt>com.akathist.maven.plugins.launch4j.configurationFile=./config/log4j2_config.xml</opt>
<jar>${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</jar>
<outfile>${project.build.directory}/MyExe.exe</outfile>
<downloadUrl>http://java.com/download</downloadUrl>
<classPath>
<mainClass>de.my.path.MainClass</mainClass>
<!-- <preCp>anything</preCp> -->
</classPath>
<!-- <icon>${project.basedir}/src/main/assembly/application.ico</icon> -->
<jre>
<minVersion>1.7.0_00</minVersion>
<!-- <jdkPreference>preferJre</jdkPreference> -->
</jre>
</configuration>
</execution>
</executions>
</plugin>
My question is now:
How can I set the system property for the log4j2 integration?!
If tried to put it in brackets with "opt" (http://launch4j.sourceforge.net/docs.html)
or something like that:
<vars>
<var>-Dlog4j.configurationFile=./config/log4j2_config.xml</var>
</vars>
But both did not work and my logger wasn't logging..
Maybe you had the same problem and can help me.
Thank you for your help!
log4j2.xml
and put it in the src folder (http://stackoverflow.com/questions/25487116/log4j2-configuration-no-log4j2-configuration-file-found) worked!! For now, I've written the author of the plugin, because the opportunity to add system propoerties should be possible and is a little bit nicer solution, in my opinion.. ;) – mrbela Feb 24 '15 at 11:18