【发布时间】:2014-03-28 12:20:43
【问题描述】:
我只是想知道是否有任何方法可以为 LOG4J 中的属性替换提供默认值?
我想在 java 系统属性中传递文件路径,然后将其与“${env:mySystemProperty}”一起使用。但是如果开发者忘记设置这个属性怎么办?然后我想在 log4j2.xml 中定义一些有意义的默认值。
知道如何实现这个功能吗?
编辑:
env 替换对我不起作用:
standalone.conf
-DoauthLoginLogPath=/path/oauth2.log
log4j2.xml
<Appender type="File" name="File" fileName="${env:oauthLoginLogPath}" immediateFlush="true">
<Appender type="File" name="File" fileName="${sys:oauthLoginLogPath}" immediateFlush="true">
我可以在 wildfly 控制台中看到该属性,我重新启动了服务器但我无法完成它。
【问题讨论】: