正如我使用Log4j2测井工具,这是通过使用系统属性(/ VM参数),使用调用:添加对Launch4j系统属性Maven中(使用的Log4j 2)
-Dlog4j.configurationFile=./config/log4j2_config.xml
对于编译我使用Maven创建的项目以及创建exe文件Launch4j(Plugin:com.akathist.maven.plugins.launch4j)。
在我的pom.xml的插件定义看起来像这样:现在
<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>
我的问题是:
我如何可以设置log4j2集成的系统属性?
如果试图把它放在括号与“选择”(http://launch4j.sourceforge.net/docs.html)
或类似的东西:
<vars>
<var>-Dlog4j.configurationFile=./config/log4j2_config.xml</var>
</vars>
但两者没有工作,我的记录器不记录..
也许你有同样的问题,可以帮助我。
谢谢你的帮助!
嘿!第一个机会没有工作..文件重命名
log4j2.xml
,并把它放在src文件夹(http://stackoverflow.com/questions/25487116/log4j2-configuration-no-log4j2-configuration-file-found)的工作! !现在,我写了这个插件的作者,因为在我看来,添加系统属性的机会应该是可能的,并且是一个更好的解决方案。 – mrbela 2015-02-24 11:18:34