'Log4j2 2.17.0 Context Lookups in Property tags replacement

We recently updated our version of Log4j2 to 2.17.0 due to the recent vulnerability. However since the upgrade, certain context lookups no longer seem to work. I read this article that states:

Mitigations include applying the 2.17.0 patch and replacing Context Lookups like ${ctx:loginId} or $${ctx:loginId} with Thread Context Map patterns (%X, %mdc, or %MDC) in PatternLayout in the logging configuration.

This is an example of what we have currently:

<Property name="filename.trans_log">${sys:access.log.location}/${web:contextPath}_transaction_$${ctx:txLogRecordType}.log
</Property>

Added to the MDC in Java:

MDC.put("txLogRecordType", eventType);

Which is now producing logs looking like

meanwhileinhell_transaction_${ctx.txLogRecordType}_2022-01-27-16.log

As far as I'm aware you cannot add a PatternLayout to Property types, so can anyone tell me if there is a way, through configuration alone, that I can get this property to substitute?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source