Re: PatternLayout caching system property lookup values
"Piotr P. Karwasz" <[email protected]> Fri, 18 Nov 2022 16:47:36 +0100
| Newsgroups | gmane.comp.jakarta.log4j.user |
|---|---|
| Message-ID | <CAFmygFaES6SPRaWmfsvG4uytDb8+NSya_O52HPbXyT=8DhDcqA@mail.gmail.com> |
Hi Stig, On Fri, 18 Nov 2022 at 11:03, Stig Døssing <[email protected]> wrote: > Is there a way to disable this “permanent substitution” and get log4j to do the system property lookup for every log event, even if there is a default value? If not, should there be? System properties can be changed from inside the application, so it seems strange to assume that if a system property has a value during logging init, it will keep that same value permanently. The `${...}` placeholders are replaced at configure time. If no value is available, they are left as is (this is IMHO a bug). If you want to evaluate the lookup at each logging event, just escape the dollar sign: `$${sys:testProperty}`. At configuration time one dollar sign will be stripped, so that the lookup will be performed at every logging event. Piotr