When the configuration is read all variables are resolved, so every variable
with a single $ will be replaced with its value. When a variable needs to be
resolved at run time you must use 2 $ characters. The first will be stripped
off leaving the variable reference. That property will then be evaluated at the
appropriate time.
In the configuration below $${env:USER} would be evaluated for each log event.
However, since “env” means it is an environment variable it is unlikely this
value will change at runtime so it could have been specified with a single $.
If it had been $${mdc:USER} then the USER variable from the thread context at
the time the log event is processed would be substituted.
Ralph
> On Jan 3, 2018, at 5:40 PM, Behrang Saeedzadeh <[email protected]> wrote:
>
> From the docs, $$ inside the <pattern> element:
>
>
> 1. <File name="Application" fileName="application.log">
> 2. <PatternLayout>
> 3. <pattern>%d %p %c{1.} [%t] $${env:USER} %m%n</pattern>
> 4. </PatternLayout>
> 5. </File>
>
>
> Also from the docs, $ inside the header attribute:
>
>
> 1. <File name="Application" fileName="application.log">
> 2. <PatternLayout header="${java:runtime} - ${java:vm} - ${java:os}">
> 3. <Pattern>%d %m%n</Pattern>
> 4. </PatternLayout>
> 5. </File>
>
>
> I just read the docs on property substitution and how StrLookup treat
> variables with multiple leading '$' characters, but it is not obvious to me
> why in the two examples above, in one example two leading $ signs are used,
> and in the other only one $ is used.
>
> Best regards,
> Behrang Saeedzadeh
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]