private boolean maybeInstallSlf4jBridgeHandler()

in src/main/java/org/apache/sling/commons/log/logback/internal/LogConfigManager.java [477:509]


    private boolean maybeInstallSlf4jBridgeHandler(@NotNull BundleContext bundleContext) {
        // SLING-2373
        boolean julSupport = converter
                .convert(bundleContext.getProperty(LogConstants.JUL_SUPPORT))
                .defaultValue(false)
                .to(Boolean.TYPE);
        if (julSupport) {
            if (!isClassNameVisible("org.slf4j.bridge.SLF4JBridgeHandler")) {
                logger.warn("Failed to re-configure the SLF4JBridgeHandler since that class was not found. "
                        + "Check if the jul-to-slf4j bundle is deployed.");
            } else if (!SLF4JBridgeHandler.isInstalled()) {
                // make sure configuration is empty unless explicitly set
                if (System.getProperty(LogConstants.SYSPROP_JAVA_UTIL_LOGGING_CONFIG_FILE) == null
                        && System.getProperty(LogConstants.SYSPROP_JAVA_UTIL_LOGGING_CONFIG_CLASS) == null) {
                    // reset the JUL logging configuration to empty
                    java.util.logging.LogManager.getLogManager().reset();
                    logger.debug("The JUL logging configuration was reset to empty");
                } else {
                    logger.debug(
                            "The JUL logging configuration was not reset to empty as JUL config system properties were set");
                }

                // enable the JUL handling
                SLF4JBridgeHandler.removeHandlersForRootLogger();
                SLF4JBridgeHandler.install();
                java.util.logging.Logger.getLogger("")
                        .setLevel(java.util.logging.Level.FINEST); // Root logger, for example.
            } else {
                logger.debug("Failed to re-confiugre JUL as the SLF4JBridgeHandle was already installed elsewhere");
            }
        }
        return julSupport;
    }