1

There is a property in my pom.xml that I'd like to use in log4j2.xml. However log4j2 seems to not detect that property and the file cannot be created.

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:

fileName="${sys:log.location}"
Anshu
  • 1,277
  • 2
  • 13
  • 28
PatrykTraveler
  • 105
  • 1
  • 1
  • 11
  • 1
    check this https://stackoverflow.com/questions/48813686/how-to-get-log4j2-properties-file-to-read-filename-from-pom-xml-in-spring-boot use @xxxxx@ instead of ${xxxxx} it will work. – Victor Jul 10 '19 at 13:03
  • It just creates a directory with that name and doesn't use a system property. – PatrykTraveler Jul 10 '19 at 13:25

1 Answers1

0

In your log4j2.xml file Use <property name="fileName">${filename}</property> // this will fatch your filename from pom.xml

than use "${fileName}" wherever you want to use in your log4j2. this way it will work.

Victor
  • 23
  • 3