Thanks, you are obviously correct. The fist ‘$’ is stripped during 
configuration processing. It would be up to the Route to perform substitution 
on the key, which it does not. 

Ralph

> On Jan 12, 2021, at 2:49 AM, Stamatis Zampetakis <zabe...@apache.org> wrote:
> 
> Thanks for the feedback Ralph.
> 
> Actually having the pattern and the key be the same expression does not mean 
> it will always match. What actually happens is that the lookup is applied in 
> the pattern so $${ctx:queryId} becomes let's say "query0" but the key of the 
> route remains "${ctx:queryId}" (one dollar '$' stripped). 
> The code ends up doing "query0".equals("${ctx:queryId}"), which returns 
> false, and thus the route does not match.
> 
> Another interesting thing, which I discovered yesterday, is that if there is 
> no value in the log4j context then we end up doing 
> "${ctx:queryId}".equals("${ctx:queryId}") so the specific route will be 
> chosen.
> 
> I don't know the original intentions behind this logging definition but I 
> doubt that it was what happens here. At the moment, I am mostly trying to 
> understand if it is normal that lookups are not applied in the key of the 
> route.
> 
> Best,
> Stamatis
> 
> On 2021/01/11 15:38:47, Ralph Goers <ralph.go...@dslextreme.com> wrote: 
>> You are correct in your assessment. The default route is the one that does 
>> not have a key. Naming a route “default” doesn’t make it the default. The 
>> value of the key is the value that is required for the route to match. 
>> Having the pattern and key be the same expression means it will always 
>> match, which makes the routing appender useless.
>> 
>> Ralph
>> 
>>> On Jan 11, 2021, at 4:01 AM, Stamatis Zampetakis <zabe...@gmail.com> wrote:
>>> 
>>> Hello,
>>> 
>>> During code review I bump into a configuration (snippet below) for a
>>> routing appender that seems wrong in various aspects.
>>> 
>>> appender.query-routing.type = Routing
>>> appender.query-routing.name = query-routing
>>> appender.query-routing.routes.type = Routes
>>> appender.query-routing.routes.pattern = $${ctx:queryId}
>>> # purge policy
>>> ...
>>> # default route
>>> appender.query-routing.routes.route-default.type = Route
>>> appender.query-routing.routes.route-default.key = $${ctx:queryId}
>>> appender.query-routing.routes.route-default.ref = RFA
>>> # queryId based route
>>> appender.query-routing.routes.route-mdc.type = Route
>>> appender.query-routing.routes.route-mdc.file-mdc.type = RandomAccessFile
>>> appender.query-routing.routes.route-mdc.file-mdc.name = query-file-appender
>>> ...
>>> 
>>> I've never used the routing appender before so I would be grateful if
>>> somebody could verify the findings below.
>>> 
>>> First, the naming pattern (and comment) indicating that the first route
>>> (route-default) is the default one seems to be wrong.
>>> Based on the documentation [1], if there is no key definition for a route
>>> then that one is the default; so in this case the second route seems to be
>>> the default and not the first one.
>>> 
>>> The lookup based key definition in the first route seems to be useless.
>>> Although not explicitly stated in the doc [1] from the code it seems that
>>> only static literals (not lookups) are supported in route keys.
>>> 
>>> All in all, at the current state the route-default seems to be useless and
>>> I suppose can be removed.
>>> 
>>> Best,
>>> Stamatis
>>> 
>>> [1]
>>> https://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 



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

Reply via email to