[ 
https://issues.apache.org/jira/browse/LOG4J2-1589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15823881#comment-15823881
 ] 

Dmitriy Neretin commented on LOG4J2-1589:
-----------------------------------------

Hello [~rem...@yahoo.com], [~garydgregory]

I'v experimented with a source code for a while to understand how it actually 
works at all and the substitute algorithm in the StrSubstitutor is not the 
simplest :) What I found out is - it's not a missing feature. It's only a bug. 
I will provide detailed description later (what was a problem and how to fix 
it). The problem is in the StrSubstitutor. If I activate the 
'enableSubstitutionInVariables' field it solves the problem. But there are some 
points I not understand:
- Why is it always deactivated? With deactivated I mean 'false'. The setter 
method is not used. So the value will be never changed.
- I didn't see the possibility to activate this field by configuration, so I 
changed it directly in the code, installed it in the local maven repo and 
worked with local framework version
- I have fear, if I activate the field it can produce some regression issues... 
And I don't understand the framework good enough to prevent it :)

My personal proposal: we left the field as is (false) but additionally check 
the property if the default property value is also a variable: ":-${" and only 
then we set it to true. After substitution we set it to false again. If you 
think it is a reasonable solution (or maybe you have a better solution) I could 
provide a patch.

> Value nesting during property substitution
> ------------------------------------------
>
>                 Key: LOG4J2-1589
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1589
>             Project: Log4j 2
>          Issue Type: Wish
>          Components: Configurators
>    Affects Versions: 2.5
>            Reporter: Dmitriy Neretin
>            Priority: Minor
>              Labels: features
>
> There is already a good description what "default value nesting" is: 
> http://logback.qos.ch/manual/configuration.html#nestedSubst
> It is partially implemented in the log4j but it can still be improved.
> Example from that page above: 
> - "${id:-${userid}}" If the *id* variable is not set, *userid* will be used.
> At the moment it works only if the default value is a concrete value:
> - ${path:-/only/concrete/path/can/be/used/here}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org

Reply via email to