[D] Should CoreLogger override `addHandler`/`removeHandl er` to avoid warnings from PR #3125? [logging-log4j2]
mpritham (via GitHub) <[email protected]> Mon, 16 Mar 2026 22:38:01 -0000
| Newsgroups | gmane.comp.jakarta.log4j.devel |
|---|---|
| Message-ID | <[email protected]> |
GitHub user mpritham created a discussion: Should CoreLogger override `addHandler`/`removeHandler` to avoid warnings from PR #3125?
# Context
PR #3125 added overrides to ApiLogger for JUL mutator methods (addHandler, removeHandler, setUseParentHandlers, etc.) that log a WARN via StatusLogger:
```Ignoring call to `j.u.l.Logger.addHandler(...)`, since the Log4j API does not provide methods to modify the underlying implementation.```
I understand how this makes sense for [ApiLogger](https://github.com/apache/logging-log4j2/blob/2.x/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLogger.java): the JavaDoc describes it as the "Log4j API implementation" that explicitly does not use java.util.logging.Handler, and it only holds a reference to ExtendedLogger (a log4j-api type).
My understanding is that [CoreLogger](https://github.com/apache/logging-log4j2/blob/2.x/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java) is an implementation of a JUL Logger with direct access to `org.apache.logging.log4j.core.Logger`, `Configurator`, and `LoggerConfig`. It already overrides `setLevel`, `getLevel`,
`setUseParentHandlers`, `getUseParentHandlers`, and `getParent` with working implementations.
However, `CoreLogger` doesn't override `addHandler` or `removeHandler`, so it inherits `ApiLogger`'s new warning behavior.
I'm using CoreLoggerAdapter via:
```
log4j.jul.LoggerAdapter = org.apache.logging.log4j.jul.CoreLoggerAdapter
```
This means that even with `CoreLoggerAdapter` configured, calls like `SLF4JBridgeHandler.install()` (which calls `Logger.getLogger("").addHandler(...))` produce the warning.
# Question
Was this intentional, or would it make sense for CoreLogger to override addHandler/removeHandler as well — either with a working implementation or at least without the warning?
Thanks for all the work on Log4j!
GitHub link: https://github.com/apache/logging-log4j2/discussions/4066
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]