[ https://issues.apache.org/jira/browse/LOG4J2-1013?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14549769#comment-14549769 ]
Gary Gregory commented on LOG4J2-1013: -------------------------------------- I'm not sure how to solve this yet but there is something funky going on. If you run {{org.apache.logging.log4j.core.lookup.MainInputArgumentsLookupTest}} from Eclipse (for example) with the command line {{--file foo.txt}} you will see: {noformat} 2015-05-18 21:27:03,180 [main] [foo.txt][1][-file] ERROR: this is an error message {noformat} The {{PatternLayout}} config is: {noformat} %d [%t] [${main:1}][${main:-1}][${main:--file}] %-5level: %msg%n%throwable {noformat} The {{org.apache.logging.log4j.core.lookup.StrSubstitutor.DEFAULT_VALUE_DELIMITER}} is: {code:java} public static final StrMatcher DEFAULT_VALUE_DELIMITER = StrMatcher.stringMatcher(":-"); {code} If I change it to: {code:java} public static final StrMatcher DEFAULT_VALUE_DELIMITER = StrMatcher.stringMatcher(":"); {code} The output is no good at all: {noformat} 2015-05-18 21:29:48,255 [main] [1][-1][--file] ERROR: this is an error message {noformat} If I change it to: {code:java} public static final StrMatcher DEFAULT_VALUE_DELIMITER = StrMatcher.stringMatcher("***"); {code} The output is good: {noformat} 2015-05-18 21:30:31,470 [main] [foo.txt][${main:-1}][foo.txt] ERROR: this is an error message {noformat} What seems to happen is that the proper resolving mechanics need {{"main:1"}} and {{"main:--file"}} to be passed down from {{org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(LogEvent, StringBuilder, int, int, List<String>)}} so that the lookup can then break up the {{"main"}} from the {{"1"}} and the {{"--file"}}. The problem is when the {{StrSubstitutor}} itself breaks up {{"main:--file"}} since it is configured with a {{DEFAULT_VALUE_DELIMITER = StrMatcher.stringMatcher(":-")}}. There seems to be a conflict between the {{StrSubstitutor}} we copied from Commons Lang and our {{StrLookup}}s. Help, thoughts and fixes welcome. Thank you, Gary > 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