Usually when you add logging to your application you create a java.util.logging.Logger that has the same name as the class you use the Logger in. Your code might look like this:
package some.test;</p>import java.util.logging.Logger;
public class Main {
private static Logger log = Logger.getLogger(Main.class.getName());public static void main(final String[] args) {
log.info("test");
}
}
</pre>This works well and you get something like this as the log output:
01.04.2012 19:10:39 some.test.Main main
INFO: test
</pre></p>Now we can easily change the configuration of this logger and change the Loglevel. So for instance when we don't like any logging we can disable logging for this class either using a configuration file or do it directly from code like so:
Logger.getLogger("some.test").setLevel(Level.OFF);</pre></p>and the class will not log anymore.
Sometimes doing this in Nifty and using the name "de.lessvoid.nifty" for instance to shut off the logging refused to work. Some classes simply didn't stop logging at all. What's going on?
After a long headache we've finally found out!
Nifty used some special logger names for eventbus and inputevent logging. Both loggers used special names that did not relate to any class because there where several classes that would need to log those events. So a special name, like "NiftyEventBusLog" made sense for me.
In some places we had code like that:
package some.test;</p>import java.util.logging.Logger;
public class Main {
private static Logger differentLog = Logger.getLogger("SpecialLog");public static void main(final String[] args) {
differentLog.info("test");
}
}
</pre>I somehow expected the loggername in the log to be "SpecialLog" since it's the name of the logger. But in fact we get something else:
01.04.2012 19:24:41 some.test.Main main
INFO: test
</pre></p>O_o
The information still shows "some.test.Main" since this is the class that actually logged!
If you now try to disable logging for this class, like we've seen above:
Logger.getLogger("some.test").setLevel(Level.OFF);</pre></p>YOU WOULD STILL SEE THE LINE IN THE LOG - even though you've disabled it (kinda) :-)
Of course to fix this you would need to disable the "SpecialLog" additionaly to "some.test.Main" but that's pretty odd since you usually don't know the exact names of all loggers beforehand.
So to make a long story short Nifty now (current git) removed all the special loggers and always only uses the logger with the name of the current class. When you now disable a logger you should be pretty sure that you really disable any output with that name ;-)
void
EDIT</strong></p>
I just realized that it would be very helpful to give you the actual logger names you need to disable when you still use Nifty 1.3.1:
- "NiftyInputEventHandlingLog"</li>
- "NiftyEventBusLog"</li>
- "NiftyImageManager"</li>
</ul></p>