### Question:
LogUtils { public static boolean setLogBackLevel(String loggerName, String logLevel) { String logLevelUpper = (logLevel == null) ? "OFF" : logLevel.toUpperCase(); try { Package logbackPackage = Package.getPackage(LOGBACK_CLASSIC); if (logbackPackage == null) { LOG.warn("Logback is not in the classpath!"); return false; } if ((loggerName == null) || loggerName.trim().isEmpty()) { loggerName = (String) getFieldVaulue(LOGBACK_CLASSIC_LOGGER, "ROOT_LOGGER_NAME"); } Logger loggerObtained = LoggerFactory.getLogger(loggerName); if (loggerObtained == null) { LOG.warn("No logger for the name: {}", loggerName); return false; } Object logLevelObj = getFieldVaulue(LOGBACK_CLASSIC_LEVEL, logLevelUpper); if (logLevelObj == null) { LOG.warn("No such log level: {}", logLevelUpper); return false; } Class<?>[] paramTypes = {logLevelObj.getClass()}; Object[] params = {logLevelObj}; Class<?> clz = Class.forName(LOGBACK_CLASSIC_LOGGER); Method method = clz.getMethod("setLevel", paramTypes); method.invoke(loggerObtained, params); LOG.info("LogBack level set to {} for the logger '{}'", logLevelUpper, loggerName); return true; } catch (NoClassDefFoundError e) { LOG.warn("Couldn't set logback level to {} for the logger '{}'", logLevelUpper, loggerName, e); return false; } catch (Exception e) { LOG.warn("Couldn't set logback level to {} for the logger '{}'", logLevelUpper, loggerName, e); return false; } } private  LogUtils(); static void update(Map conf); static boolean setLogBackLevel(String loggerName, String logLevel); static boolean setLog4jLevel(String loggerName, String logLevel); static final String LOGBACK_CLASSIC; static final String LOGBACK_CLASSIC_LOGGER; static final String LOGBACK_CLASSIC_LEVEL; static final String LOG4J_CLASSIC; static final String LOG4J_CLASSIC_LOGGER; static final String LOG4J_CLASSIC_LEVEL; static Long lastChangeTS; }### Answer:
@Test public void testSetLogBackLevel() throws Exception { assertEquals(true, LogUtils.setLogBackLevel(null, null)); assertEquals(true, LogUtils.setLogBackLevel(null, "TRACE")); assertEquals(true, LogUtils.setLogBackLevel(".", "DEBUG")); assertEquals(true, LogUtils.setLogBackLevel(null, "INFO")); assertEquals(true, LogUtils.setLogBackLevel(null, "WARN")); assertEquals(false, LogUtils.setLogBackLevel(null, "WARNING")); assertEquals(false, LogUtils.setLogBackLevel(null, "")); assertEquals(false, LogUtils.setLogBackLevel(null, "-")); assertEquals(true, LogUtils.setLogBackLevel("org.", "DEBUG")); }