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

Ralph Goers commented on LOG4J2-1013:
-------------------------------------

As far as StrSubstitutor is concerned all variables are of the form 
${key:-defaultValue}.  StrSubstituor uses Lookups to resolve the key into a 
value. The Interpolator is a "special" Lookup that subdivides the key into 
"LookupName:key". The default value portion should be left alone and should 
only be used when the key cannot be resolved. The problem I believe you are 
having is that StrSubstitutor is seeing the ":-" and is removing that along 
with the "-file" to use as the default value. Changing the value to ":" is just 
going to make things worse.

I don't know that we document that you can have default values for lookups, but 
the syntax would be ${lookup:key:-defaultValue}.  As you noted we could change 
the default value delimiter to something else that we know wouldn't cause a 
problem - if you know what that is. Perhaps ";-" would work better since that 
would distinguish it from the Lookup key.

> Log4j2 Main Arguments Lookup by name doesn't work
> -------------------------------------------------
>
>                 Key: LOG4J2-1013
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1013
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API, Core, Lookups
>    Affects Versions: 2.2
>         Environment: Windows 7 x64 Ultimate and Java 8U31 x64. Project 
> created using Eclipse.
>            Reporter: Ioan Mihaila
>            Priority: Critical
>
> Accessing Main Arguments by using index based look up works : ${main:0}
> Accessing Main Arguments by using name based look up doesn't work : 
> ${main:--file}
> When trying to access by name it doesn't retrieve the argument but retrieves 
> "-file".



--
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