
I thing you should check if the level is != null, i.e. if (log.getLevel() != null) { strList.add(log.getName()); } cheers jl On Tue, Nov 11, 2008 at 05:07, Gunnar Hillert <gunnar@hillert.com> wrote:
How do I get a list of configured loggers (In logback.xml) programmatically?
e.g. I have the following loggers configured in my logback.xml file:
... <logger name="org.springframework.security"> <level value="DEBUG"/> </logger> <logger name="org.apache.struts"> <level value="INFO"/> </logger> ...
How do I get those loggers? (E.g. I like to dynamically inspect and change my setup loggers at runtime)
I was able to do this easily in Log4J but I seem to have issues doing so in logback.
I thought I could do:
LoggerContext lc = ((ch.qos.logback.classic.Logger)LOGGER).getLoggerContext(); List<String> strList = new ArrayList<String>(); Iterator<ch.qos.logback.classic.Logger> it = lc.getLoggerList().iterator(); while(it.hasNext()) { Logger log = it.next(); strList.add(log.getName()); }
But this basically adds hundreds of loggers but I only want the ones I have configured in my logback.xml file.
What do I miss here?
Thanks a lot!
Gunnar
-- View this message in context: http://www.nabble.com/How-do-I-get-a-list-of-configured-loggers--tp20433216p... Sent from the Logback User mailing list archive at Nabble.com.
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user