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