Good idea! One way I like to think about this is what is the API I need to build a tree view UI that shows the logger hierarchy where I can toggle levels for one logger or one logger tree (including the root).
>set the configured level of a single logger Some people (like me) will want to enable debug all in one go for example, even for loggers that have not been instantiated yet. I think we should distinguish whether this is set the level for a hierarchy for just the one and the one only. A simpler primitive might be get all current logger names, not sure. Ty, Gary On Thu, Oct 31, 2024, 11:12 AM Piotr P. Karwasz <pi...@mailing.copernik.eu> wrote: > 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 > >