[logback-dev] Better introspection into logging setup

Robert Elliot rob at lidalia.org.uk
Tue Mar 2 00:17:31 CET 2010


On 1 Mar 2010, at 18:55, Robert Elliot wrote:
> 
> However, oddly you can't then ask the root logger what children it has - it's stored as a private variable (List<Logger> childrenList) with no public accessor.  I don't know what the reason for this is (I'm also curious why it's a List - it looks like a Set to me, order irrelevant but no duplicates).  I see no reason why it shouldn't have a public accessor exposing an unchangeable view of this collection to allow the introspection you ask for - you could then recursively walk the Logger tree.  It would be trivial to branch logback in git and implement this.

I've got my own reasons for wanting this functionality, so I've raised a JIRA here:
http://jira.qos.ch/browse/LBCLASSIC-190

and created the logback fork that does the work here:
http://github.com/Mahoney/logback

> Another approach might be to look at the Joran configurator for logback and add a listener to it as each Logback logger is configured that creates the corresponding JULI logger (if that's the right JULI terminology).

It looks as if you can just add a status listener class of your own writing to your logback.xml:

<configuration>
  <statusListener class="com.whatever.YourStatusListener" />  

  ... the rest of the configuration file  
</configuration>

Joran will pass it messages as it configures each Logger - see the source of ch.qos.logback.classic.joran.action.LoggerAction for details.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-dev/attachments/20100301/46bd8233/attachment.html>


More information about the logback-dev mailing list