/** * Attempts to enable SLF4J logging via logback or log4j. * * This will first check whether the logging has been enabled using the * return value of {@link #isEnabled()}. * * @return {@code true} if logging was successfully enabled by this method */ public static synchronized boolean enableLogging() { if (isEnabled()) return false; for (String[] toolClass : TOOL_CLASSES) { try { Class<?> k = Class.forName(toolClass[0] + toolClass[1]); Method m = k.getMethod("enableLogging"); m.invoke(null); return true; } catch (ReflectiveOperationException|LinkageError t) { // no-op. Ignore error and try the next class. } } return false; }
/** * Attempts to enable SLF4J logging via logback or log4j. * * This will first check whether the logging has been enabled using the * return value of {@link #isEnabled()}. * * @return {@code true} if logging was successfully enabled by this method */ public static synchronized boolean enableLogging() { if (isEnabled()) return false; for (String[] toolClass : TOOL_CLASSES) { try { Class<?> k = Class.forName(toolClass[0] + toolClass[1]); Method m = k.getMethod("enableLogging"); m.invoke(null); return true; } catch (ReflectiveOperationException|LinkageError t) { // no-op. Ignore error and try the next class. } } return false; }