https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

            Bug ID: 64398
           Summary: New "default values in property value expressions"
                    syntax breaks Log4j2's "property substitution" syntax
           Product: Tomcat 8
           Version: 8.5.54
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: frank.er...@androme.be
  Target Milestone: ----

In Tomcat 8.5.54, the following commit was added:

https://github.com/apache/tomcat/commit/dcf3193bd6a293492fb7efe756827aece33f4a51

This uses the syntax ${foo:bar} to mean "If 'foo' is undefined, replace with
'bar'"


Log4j2 has a feature called "property substitution":

http://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution
http://logging.apache.org/log4j/log4j-2.12.1/manual/lookups.html

For example, ${env:fooConfDir} is replaced with the value of the environment
variable "fooConfDir".


Due to the commit in 8.5.54, ${env:fooConfDir} instead now gets replaced with
the literal value "fooConfDir" (assuming no variable named "env" is defined).

In our case, we have the following lines in our web.xml (redacted):

        <context-param>
                <param-name>log4jConfiguration</param-name>
               
<param-value>file://${env:fooConfDir}/foo/log4j2.xml</param-value>
        </context-param>


As of Tomcat 8.5.54, Log4j fails to find its configuration file with the
following error:

ERROR StatusLogger Unable to access file://fooConfDir/foo/log4j2.xml
java.net.UnknownHostException: fooConfDir


It appears that the new syntax linked above interferes with Log4j's property
substitution.

Recommend changing the "default" syntax to ${foo:-bar} as this is also the
syntax used by Log4j:
https://logging.apache.org/log4j/2.x/manual/configuration.html#DefaultProperties

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to