简体   繁体   English

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

[英]Using pom.xml SystemProperty in log4j2 configuration file

There is a property in my pom.xml that I'd like to use in log4j2.xml. 我想在log4j2.xml中使用pom.xml中的一个属性。 However log4j2 seems to not detect that property and the file cannot be created. 但是,log4j2似乎无法检测到该属性,因此无法创建该文件。

The property is defined in a following way: 该属性通过以下方式定义:

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

And that how I refer to that in a log4j2.xml: 那就是我在log4j2.xml中的引用方式:

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

In your log4j2.xml file Use <property name="fileName">${filename}</property> // this will fatch your filename from pom.xml 在您的log4j2.xml文件中,使用<property name="fileName">${filename}</property> //这将使pom.xml中的文件名无效

than use "${fileName}" wherever you want to use in your log4j2. 而不要在log4j2中使用的任何地方使用“ $ {fileName}”。 this way it will work. 这样,它将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM