gpt4 book ai didi

java - 在log4j2配置文件中使用pom.xml SystemProperty

转载 作者:行者123 更新时间:2023-12-02 03:15:20 24 4
gpt4 key购买 nike

我的 pom.xml 中有一个属性,我想在 log4j2.xml 中使用。但是 log4j2 似乎没有检测到该属性,因此无法创建该文件。

该属性按以下方式定义:

<systemProperty>
<name>log.location</name>
<value>${project.build.directory}/logs</value>
</systemProperty>

我是如何在 log4j2.xml 中引用它的:

fileName="${sys:log.location}"

最佳答案

在您的 log4j2.xml 文件中使用 <property name="fileName">${filename}</property>//这将从 pom.xml 中提取你的文件名

而不是在 log4j2 中任何您想使用的地方使用“${fileName}”。这样就可以了。

关于java - 在log4j2配置文件中使用pom.xml SystemProperty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56965727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com