LoggingConfigurator { public static void init(Configuration config) { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); Configuration logLevels = config.strippedSubset(ConfigurationPrefixes.LOGGING_CONFIG_PREFIX); for (String key : logLevels.getKeys()) { lc.getLogger(key).setLevel(Level.toLevel(logLevels.getString(key))); } } private  LoggingConfigurator(); static void init(Configuration config);  }
@Test public void configure() { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger l = context.getLogger(LoggingConfiguratorTest.class); assertNotNull(l); assertNull(l.getLevel()); Map<String, String> logLevels = new HashMap<>(); String key = ConfigurationPrefixes.LOGGING_CONFIG_PREFIX + LoggingConfiguratorTest.class.getName(); logLevels.put(key, "DEBUG"); LoggingConfigurator.init(new MapConfiguration(logLevels)); assertNotNull(l.getLevel()); assertEquals(Level.DEBUG, l.getLevel()); }