Skip to content

Make warning about JUL mutator usage less verbose #3281

@ppkarwasz

Description

@ppkarwasz

PR #3125 adds status logger warnings, each time user code calls one of the mutator methods of j.u.l.Logger:

2024-12-04T11:13:21.273591100Z VelocityControl - Task Executor #0 WARN Ignoring call to `j.u.l.Logger.setLevel(OFF)`, since the Log4j API does not provide methods to modify the underlying implementation.
To modify the configuration using JUL, use an `AbstractLoggerAdapter` appropriate for your logging implementation.
See https://logging.apache.org/log4j/3.x/log4j-jul.html#log4j.jul.loggerAdapter for more information.
2024-12-04T11:13:21.274590Z VelocityControl - Task Executor #0 WARN Ignoring call to `j.u.l.Logger.setLevel(false)`, since the Log4j API does not provide methods to modify the underlying implementation.
To modify the configuration using JUL, use an `AbstractLoggerAdapter` appropriate for your logging implementation.
See https://logging.apache.org/log4j/3.x/log4j-jul.html#log4j.jul.loggerAdapter for more information.
2024-12-04T11:13:21.276589400Z VelocityControl - Task Executor #0 WARN Ignoring call to `j.u.l.Logger.addHandler(java.util.logging.ConsoleHandler@5ce92a4a)`, since the Log4j API does not provide methods to modify the underlying implementation.
To modify the configuration using JUL, use an `AbstractLoggerAdapter` appropriate for your logging implementation.
See https://logging.apache.org/log4j/3.x/log4j-jul.html#log4j.jul.loggerAdapter for more information.

While I believe that these warnings are important to inform the application developer that something is trying to mess with the logging configuration, they might be too verbose for application users. We should probably adopt a similar strategy as Java with the illegal reflective calls:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/azureuser/server-0.28.0-SNAPSHOT.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

In particular:

  • The warning should mention the caller of the method.
  • The warning should suggest reporting the problem to the maintainer of the caller class.
  • There should be a Log4j option to decide how many times the warning should appear, e.g. log4j2.julMutatorAccess with values warn-once (default), ignore and warn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions