How can I set the log-level from nifty?
I tried this:
Logger.getLogger(“de.lessvoid.nifty”).setLevel(Level.WARNING);
before and after the NiftyJmeDisplay-Creation. but it doesn’t work. I got all infos, too.
Try this:
[java]Logger root = Logger.getLogger("");
Handler[] handlers = root.getHandlers();
for (int i = 0; i < handlers.length; i++) {
if (handlers instanceof ConsoleHandler) {
((ConsoleHandler) handlers).setLevel(Level.WARNING);
}
}[/java]
I’m not a jdk14 logging expert so if anyone knows why the above code is necessary and if there is something that Nifty can do internally so that configuring the ConsoleHandler is not necessary … I’d be happy for any hint
@void256 said:
Try this:
[java]Logger root = Logger.getLogger("");
Handler[] handlers = root.getHandlers();
for (int i = 0; i < handlers.length; i++) {
if (handlers instanceof ConsoleHandler) {
((ConsoleHandler) handlers).setLevel(Level.WARNING);
}
}[/java]
I'm not a jdk14 logging expert so if anyone knows why the above code is necessary and if there is something that Nifty can do internally so that configuring the ConsoleHandler is not necessary ... I'd be happy for any hint :)
Thanks! That worked like a charm :D. I guess it worked for @ceiphren too :P.
@void256 said:
I'm not a jdk14 logging expert so if anyone knows why the above code is necessary and if there is something that Nifty can do internally so that configuring the ConsoleHandler is not necessary ... I'd be happy for any hint :)
No idea, but I did notice Nifty's log is doing something differently ^^
@void256 are you sure that you initialize your loggers with something like Logger.getLogger(YourClass.class.getName()) ?
[java]public class Nifty {
private Logger log = Logger.getLogger(Nifty.class.getName());
…[/java]
O_o
Ok, I’ve checked again and some of the Loggers are static:
[java]private static Logger log = Logger.getLogger(Tools.class.getName());[/java]
Does that cause a problem maybe? Since they are initialized before you can configure them from your application code maybe?
yeah it was just to check …
the static modifier should not make any difference.
That’s strange that you have to go trough all the console handlers…
also this
[java]
Logger root = Logger.getLogger(“de.lessvoid”);
[/java]
should be better as you would only silence nifty’s log, in case you still want to see any other log.
yeah, this method didn’t work :/. The example that void gave before, does affect all loggers.
I think I’ve finally found an explanation why this doesn’t work. I’ve explained it on the Nifty blog.
From what I’ve learned so far (and fixed in Nifty ;)) this should work better in the upcoming Nifty 1.3.2 version…