ConfigurationOverrides { void doUpdateLogging(Element overrides, ResourceLoader loader) throws JDOMException, IOException { List<?> logOverides = Xml.selectNodes(overrides, LOGFILE_XPATH); Properties p = new Properties(); for (Object logOveride : logOverides) { String value = ((Content) logOveride).getValue(); InputStream in = loader.loadInputStream(value); if (in != null) { try { p.load(in); } finally { in.close(); } } else { throw new IllegalArgumentException("log configuration file " + value + " was not found"); } } if (logOverides.size() > 0) { LoggerRepository loggerRepo = Logger.getRootLogger().getLoggerRepository(); loggerRepo.resetConfiguration(); PropertyConfigurator configurator = new PropertyConfigurator(); configurator.doConfigure(p, loggerRepo); } } ConfigurationOverrides(final String overrides); void updateLoggingAsAccordingToOverrides(ServletContext context, Path appPath); void updateWithOverrides(String configFile, ServletContext context, Path appPath, Element configElement); Element loadXmlFileAndUpdate(String servletRelativePath, ServletContext context); List<String> loadTextFileAndUpdate(String configFilePath, ServletContext context, Path appPath, BufferedReader reader); @SuppressWarnings("unchecked") void importSpringConfigurations(XmlBeanDefinitionReader reader, ConfigurableBeanFactory beanFactory, ServletContext servletContext, Path appPath); void postProcessSpringBeanFactory(ConfigurableListableBeanFactory beanFactory, ServletContext servletContext,
                                             Path appPath); void onSpringApplicationContextFinishedRefresh(ConfigurableListableBeanFactory beanFactory, ServletContext servletContext,
                                                          Path appPath); static final String OVERRIDES_KEY; static final ConfigurationOverrides DEFAULT; }
@Test public void updateLoggingConfig() throws JDOMException, IOException { final Element overrides = Xml.loadFile(classLoader.getResource("correct-webapp/WEB-INF/overrides-config.xml")); ConfigurationOverrides.DEFAULT.doUpdateLogging(overrides, loader); assertEquals(Level.ERROR, org.apache.log4j.Logger.getRootLogger().getLevel()); }