我只是想知道是否有任何方法可以为LOG4J中的属性替换提供默认值?Log4J2属性替换 - 默认
我想在java系统属性中传递文件路径,然后在“$ {env:mySystemProperty}”中使用它。但是如果开发者忘记设置这个属性呢?然后我想在log4j2.xml中定义一些有意义的默认值。
任何想法如何实现这一功能?
编辑:
的ENV取代不为我工作:
standalone.conf
-DoauthLoginLogPath=/path/oauth2.log
log44j2.xml
<Appender type="File" name="File" fileName="${env:oauthLoginLogPath}" immediateFlush="true">
<Appender type="File" name="File" fileName="${sys:oauthLoginLogPath}" immediateFlush="true">
我可以看到wildfly安慰财产,我重新启动服务器,但我无法完成它。
它的工作原理正是您所描述的。谢谢。 –
我不知道它是否在以前的版本中工作过,但这不起作用。您必须在属性中使用': - '来定义默认值。 – GoGoris