You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2020/04/30 07:39:11 UTC

[Bug 64398] New: New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

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.erens@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

--- Comment #4 from Michael Osipov <mi...@apache.org> ---
I would also recommend to use :-. This shell/bsah default. Logback uses the
same style.

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


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
I don't like that the change in default format isn't backwards compatible but
given the popularity of log4j2 and that the Tomcat feature is relatively new, I
think this is the right thing to do.

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


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from Remy Maucherat <re...@apache.org> ---
Ok for ":-" then. This will be in 10.0-M5, 9.0.35, 8.5.55, 7.0.104.

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


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

Frank Erens <fr...@androme.be> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |frank.erens@androme.be

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


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

--- Comment #3 from Frank Erens <fr...@androme.be> ---
${variable:-default} syntax is also used by bash/sh:
https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

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


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

--- Comment #7 from Christopher Schultz <ch...@christopherschultz.net> ---
Another vote in favor of ":-"

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


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

--- Comment #6 from Frank Erens <fr...@androme.be> ---
Thank you for resolving this so quickly!

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


[Bug 64398] New "default values in property value expressions" syntax breaks Log4j2's "property substitution" syntax

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64398

--- Comment #2 from Remy Maucherat <re...@apache.org> ---
Ok, this is unfortunate.

Or maybe this feature could be skipped in some cases [with an option, skip by
default], like for web.xml and the user descriptors ? To be honest, it is
rather bad to do any property replacement at all there as it makes the webapp
non portable.

If it is kept, I don't really like ":-" as it's not intuitive, is "::" possible
instead ?

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