Insane Programming Java ramblings and finds on the net

25Mar/100

Code snippet: replacing java.util.Logger by SLF4J

This simple piece of code adapts all JUL statement to be forwarded to SLF4J:

java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger("");
Handler[] handlers = rootLogger.getHandlers();
for (Handler handler : handlers) {
    rootLogger.removeHandler(handler);
}
SLF4JBridgeHandler.install();

The first 5 lines are needed because otherwise JUL will still log to System.err.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Spam protection by WP Captcha-Free

No trackbacks yet.