Skip to content

Will Log4j2 support pre-level-check dynamic log filtering (similar to Logback's TurboFilter #3848

@little-hue

Description

@little-hue

I’ve been researching per-request dynamic logging and came across a limitation in Log4j2’s filtering model compared to Logback.

In Logback, the TurboFilter feature allows log events to be conditionally filtered before the logger’s level check is applied. This enables powerful use cases like enabling DEBUG logs for specific requests, even when the logger’s configured level is INFO.

From my understanding and recent testing, Log4j2 does not currently support this behavior. Specifically:

If a logger is configured at INFO, then all DEBUG messages are short-circuited before any Filter or ThreadContext logic is evaluated.

As a result, it's not currently possible to emit DEBUG logs on a per-request basis using MDC or filters without globally lowering the logger level to DEBUG first.

My question is:

Are there any plans for Log4j2 to support pre-level-check filtering (similar to Logback’s TurboFilter), to allow dynamic log level evaluation per request or thread context?

I understand this design may be for performance reasons, but it would be helpful to know if this kind of feature is on the roadmap or technically feasible within the current architecture.

Thank you for your excellent work on Log4j2, and I appreciate your time and insights.

Best regards,

Amy

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionTickets that are not bug reports, but questions

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions