0

I am trying to configure log4j2 logger. It uses Apache StringSubstitutor.

I want to set default root directory as "${sys:catalina.home}/webapps/${contextName}/logs/". And if property "userRootpath" has been set in logger.properties file, app should use it. I set it as "${bundle:logger:userRootpath}".

To implement this I'm trying to use ":-" variable default value delimiter which described here. But it does not work if I set it as:

<Property name="defaultCatalinaRootpath">${sys:catalina.home}/webapps/${contextName}/logs/</Property>
<Property name="logDir">${bundle:logger:userRootpath:-${defaultCatalinaRootpath}}</Property>

It always just takes ${defaultCatalinaRootpath} and never consider ${bundle:logger:userRootpath} although it has been set in logger.propeties.

If I set directory like this...

<Property name="logDir">${bundle:logger:userRootpath}</Property>

...or this...

<Property name="logDir">${sys:catalina.home}/webapps/${contextName}/logs/</Property>

...it works, so the case is not about corrupted properties initialization.

I tried to initialize properties in different ways inside ":-" structure, but nothing works for me.

How can I achieve desired behavior?

Magentai
  • 33
  • 4

1 Answers1

0

After some debug I consider this is a bug, specified for bundle variables inside ":-" structure, I reported it here: https://issues.apache.org/jira/browse/LOG4J2-2913

If you have some ideas how to get around, please share, I would be grateful.

Magentai
  • 33
  • 4