Hi all,

I have a question regarding the Routing appender. I was reading the FAQ at 
http://logging.apache.org/log4j/2.x/faq.html#separate_log_files and got 
confused by the two source code comments:

"<!-- This route is chosen if ThreadContext has no value for key ROUTINGKEY. 
-->"

and

"<!-- This route is chosen if ThreadContext has a value for ROUTINGKEY (other 
than the value 'special' which had its own route above). The value dynamically 
determines the name of the log file. -->".

As it appears to me, these two comments should be swapped to match the code 
that follows them?

I also tried to use the described dynamic naming of the log file by defining a 
route with a lookup key like this:

<Route key="$${ctx:applicationName}">

But unfortunately, this doesn't work for me using Log4j2 2.5. When I do have a 
value assigned to that key in the Thread Context, that route is never matched. 
When there's no value, the route seems to get matched, but instead the filename 
lookup (obviously) fails, i.e. I get a file like "${ctx:applicationName}.log".

If I use a fixed key (<Route key="SomeAppName">), everything works fine, even 
the filename lookup correctly resolves ${ctx:applicationName} too.

I searched the changelog but couldn't find anything about it. Did someone else 
encounter this bug?


Best regards,
Joachim Kanbach

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