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

Remko Popma commented on LOG4J2-1013:
-------------------------------------

The problem is that Interpolator is applied too late in StrSubstitutor. When 
StrSubstitutor encounters a potential $\{variable}, it first tries to split it 
up into $\{variable:-defaultValue} parts, and only after the default value part 
is stripped off, we try to apply the Interpolator. 

In our case, our intention is for "main:\-\-file" to be the passed to the 
Interpolator, where the actual key "\-\-file" is to be resolved by the 
MainMapLookup. What actually happens is that "main" is taken as the variable 
name and passed to the Interpolator. This cannot be further resolved, and the 
default value "\-file" is shown.

Instead of eagerly assigning part of the pattern to the default value, and 
resolving the key later, StrSubstitutor should resolve the lookup type first, 
and after determining the lookup type ("main:", "sys:", ...), split the pattern 
remainder in key and default value parts.


> 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
>             Fix For: 2.8
>
>
> 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