[logback-user] How do I get a list of configured loggers?
Gunnar Hillert
gunnar at hillert.com
Tue Nov 11 05:07:16 CET 2008
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--tp20433216p20433216.html
Sent from the Logback User mailing list archive at Nabble.com.
More information about the Logback-user
mailing list