apache / apache/logging-log4j2

Make warning about JUL mutator usage less verbose

Open
#3,281 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.