正如我使用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