Hi all,
In last few days I have encountered the problem of retrieving and
setting the configured level of a logger twice (in Nashorn[1] and Apache
Kafka[2]). What do you think about introducing a public API to do this
sort of things in an implementation independent way?
Currently we have `o.a.l.l.c.config.Configurator` that allows level
manipulation, but this is a Log4j Core specific class, which only works
with Log4j Core. We could publish a small API (e.g. called LogAdmin)
that allows to:
* list the configured level of all loggers,
* get the configured level of a single logger,
* set the configured level of a single logger.
The advantage of this API would be to remove a lot of custom user code
that modifies logger levels. Spring Boot has some[3], Kafka has some[4]
and I also wrote some code of this sort for my former employer (although
that one use JUL, since they refused to use Log4j Core and I bound
everything to `log4j-to-jul` instead).
I could probably sketch a small prototype that supports Log4j Core,
Logback and JUL over the weekend.
Piotr
[1] https://github.com/openjdk/nashorn/pull/19
[2] https://github.com/apache/kafka/pull/17373#discussion_r1824026165
[3]
https://docs.spring.io/spring-boot/api/java/org/springframework/boot/logging/LoggingSystem.html
[4]
https://cwiki.apache.org/confluence/display/KAFKA/KIP-495%3A+Dynamically+Adjust+Log+Levels+in+Connect