Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log4j2-Appender-like ability to filter log4j2 log events #6967

Closed
JessHolle opened this issue Oct 25, 2022 · 6 comments
Closed

log4j2-Appender-like ability to filter log4j2 log events #6967

JessHolle opened this issue Oct 25, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@JessHolle
Copy link

Unless I am missing something the current instrumentation will catch all attempts to log to a log4j2 logger -- without any regard to the target logger and/or log event severity level.

This may well result in overwhelming verbosity. It would seem that filtering control is really needed on at least combinations of these 2 dimensions (logger name and severity level).

A seemingly attractive alternative to inventing another filtering configuration would be actually use a log4j Appender -- thus allowing "normal" filtering in this space. This might entail disabling this portion of the auto instrumentation and configuring a log4j2 Appender that behaves like the current instrumentation. Or it might involve the auto-instrumentation actually creating a NullAppender with a special (configurable) name and attaching it to the root logger if it does not already exist (but re-using an existing one and its configuration otherwise) and then instrumenting calls to that Appender.

@JessHolle JessHolle added the enhancement New feature or request label Oct 25, 2022
@JessHolle
Copy link
Author

JessHolle commented Oct 25, 2022

Of course now I notice OpenTelemetryAppender...

So that's there. And if one allows the auto-configuration to do its thing then all log4j logging not filtered out by level at the logger level by the log4j configuration is exported.

So I belated discovered -Dotel.instrumentation.log4j-appender.enabled=false. It would be great if the documentation could be improved in this area to clearly denote what the auto-configuration gives you and how to filter as needed.

@trask
Copy link
Member

trask commented Oct 27, 2022

hi @JessHolle!

Unless I am missing something the current instrumentation will catch all attempts to log to a log4j2 logger -- without any regard to the target logger and/or log event severity level.

this is surprising, the auto-instrumentation is applied after the application's logger level is checked, so it should not be capturing logs without any regard to the target logger or level, can you post a repro that we can look into to see why this might be happening for you?

@trask
Copy link
Member

trask commented Oct 27, 2022

A seemingly attractive alternative to inventing another filtering configuration would be actually use a log4j Appender -- thus allowing "normal" filtering in this space

check out discussion in #5464

@JessHolle
Copy link
Author

hi @JessHolle!

Unless I am missing something the current instrumentation will catch all attempts to log to a log4j2 logger -- without any regard to the target logger and/or log event severity level.

this is surprising, the auto-instrumentation is applied after the application's logger level is checked, so it should not be capturing logs without any regard to the target logger or level, can you post a repro that we can look into to see why this might be happening for you?

As per my later comment, I belatedly tested and re-examined the code -- and discovered that the instrumentation is after logger level filtering takes place. It still doesn't give the flexibility of an Appender, though. For instance, we have a system where a fair amount of logging is done to a database -- of the same sort of material that would be covered by traces. So while the auto-instrumentation is a good first pass, documentation for disabling that and applying the OpenTelemetryAppender where more control is needed would be great.

@JessHolle
Copy link
Author

A seemingly attractive alternative to inventing another filtering configuration would be actually use a log4j Appender -- thus allowing "normal" filtering in this space

check out discussion in #5464

Thanks, I added a comment/query there -- as giving an ability to auto-instrument with minimal configuration sounds more attractive than manually configuring to use OpenTelemetryAppender.

@trask
Copy link
Member

trask commented Aug 24, 2023

closing in favor of #5464

@trask trask closed this as completed Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants