ppkarwasz commented on issue #2766:
URL: 
https://github.com/apache/logging-log4j2/issues/2766#issuecomment-2250069982

   [FYI: You are not using `ConfigurationBuilder`, which always returns a 
complete configuration. You are modifying the existing configuration using the 
internal builders of Log4j Core. Using these internal builders is more complex 
and more susceptible to breaking changes in Log4j Core]
   
   @SnobbyVirus1973,
   
   The `map` lookup always returns `null`, unless it is evaluated in the 
context of a log event (i.e. using [`StrLookup.lookup(LogEvent, 
String)`](https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/lookup/StrLookup.html#lookup(org.apache.logging.log4j.core.LogEvent,java.lang.String))
 is used instead of `StrLookup.lookup(String)`).
   Currently this only happens:
   
   * for the `pattern` attribute of `PatternLayout`,
   * for "constant" fields of `JsonTemplateLayout`,
   * for the `pattern` attribute of the `Routes` element (used in the `Routing` 
Appender).
   
   Therefore lookups like `map`, `sd` and `event` will not work in the 
`additionalFields` configuration property.
   
   Although I believe that `additionalFields` should use a log event context 
instead of the global one to evaluate runtime lookups, I am not certain which 
is the best way to do it:
   
   * a simple solution would be to add a `LogEvent` parameter to the 
`StrSubstitutor` call. This will allow `$${map:...}` to work.
   * we can also add support for `PatternConverter` patterns, which will allow 
both `$${map:...}` and `%K{...}` to work. The latter provides a better 
performance.
   
   @vy and @garydgregory: what do you think?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to