how can I configure the behaviour of the root logger in the logging api? I don't want to configure the behaviour of each logger separately, instead it would be very convenient if I have a single property file where I can set the behaviour of all loggers.
Use the following to get the root logger:
Logger system = Logger.getLogger("");
You can now access the root logger as any other logger.
In my case I was willing to make it quiet. I succeeded to do it with the following code:
private static void setLevel(Logger pLogger, Level pLevel) {
Handler[] handlers = pLogger.getHandlers();
for (Handler h : handlers) {
h.setLevel(pLevel);
}
pLogger.setLevel(pLevel);
}
...
setLevel(system, Level.OFF);
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With