logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Accessing ThreadContext via "$${ctx:ndc}" vs "${ctx:ndc}"
Date Thu, 20 Feb 2020 21:27:00 GMT
When a value doesn’t exist and you don’t specify a default value then the value of the
variable string is itself. So If you code ${ctx:ndc} and there is no value for that you will
see ${ctx:ndc} in the output.  Whenever StrSubstitutor finds a variable of the form $${ctx:ndc}
it will simply strip the leading $ and you will get ${ctx:ndc}.

Ralph

> On Feb 20, 2020, at 12:37 PM, Surendar Chandra <surendar.chandra@rubrik.com> wrote:
> 
> I'm building a JSON log by using something like this in my xml config:
> 
> <KeyValuePair key="ndc" value="$${ctx:ndc}"/>
> 
> If I use a single $, for one particular value, the value seems to be
> stuck at a constant. Other variables are fine. If I use a double $,
> then it seems to work in all scenarios. I guess I should be using $$
> but why is it flaky with a single $. Documentation states "During
> initial configuration processing the first '$' will be removed.". In
> that case I'd expect it to be {ctx:ndc} and not some other string.
> 
> Thanks
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 



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


Mime
View raw message