Details
-
Improvement
-
Resolution: Not a bug
-
Major
-
None
-
1.7.13
-
None
-
any
Description
Originally I ask at http://stackoverflow.com/questions/34475776/what-is-impact-of-using-jul-to-slf4j-several-times-in-java-ee-spring-container
Question about implication of calling SLF4JBridgeHandler.install() in container environment.
I think that SLF4J may steal log messages from other webapp and redirect them to individual log file.
Another concern is memory leaks when application is redeployed in container.
I have dug in sources code:
public class SLF4JBridgeHandler extends Handler { public static void install() { LogManager.getLogManager().getLogger("").addHandler(new SLF4JBridgeHandler()); } public static void uninstall() throws SecurityException { java.util.logging.Logger rootLogger = getRootLogger(); Handler[] handlers = rootLogger.getHandlers(); for (int i = 0; i < handlers.length; i++) { if (handlers[i] instanceof SLF4JBridgeHandler) { rootLogger.removeHandler(handlers[i]); } } } }
I am not an expert of JUL but I guess that LogManager.getLogManager().getLogger("").addHandler(...) make global registration and affect all application used in single container.