Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-351

Request for documentation improvements for SLF4JBridgeHandler and jul-to-slf4j usage.

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Not a bug
    • Icon: Major Major
    • None
    • 1.7.13
    • jul-to-slf4j
    • 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.

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            gavenkoa Oleksandr Gavenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: