-
Notifications
You must be signed in to change notification settings - Fork 993
Description
Is your feature request related to a problem? Please describe.
A possible application of the W3C Sampled Flag is to enable more detailed logging if the flag is set to true
.
To dynamically switch the log level, based on context data, Log4j Core requires a Filter
implementation that matches the log events for which the sampled flag is true
.
Describe the solution you'd like
In Log4j Core filters can be applied in one of four phases. The most efficient ones are the global filters, because they are evaluated before a log event is created and therefore before the OpenTelemetryContextDataProvider
can fill the event with context data.
It might useful to develop a Log4j Core filter that uses the OpenTelemetry API directly to determine whether the sampled flag is set for the context. The most obvious place to host such a filter is this repo (e.g. the opentelemetry-log4j-context-data-2.17-autoconfigure
artifact).
Describe alternatives you've considered
It is currently possible to decrease threshold level for log events by using a ContextMapFilter
that checks if the trace_flags
key in the context data of a log event has a value of 01
.
This is not ideal since:
- It can not be used before a log event is created.
- The configuration will break if
trace_flags
has a value different from00
or01
.
Additional context
No response