public static void main(String[] args) throws IOException { jrds.JrdsLoggerConfiguration.initLog4J();
@Override public void start(String[] args) throws Exception { System.setProperty("java.awt.headless", "true"); jrds.JrdsLoggerConfiguration.initLog4J(); Properties pm = new Properties(); File propFile = new File(propFileName); if(propFile.isFile()) pm.load(new FileReader(propFile)); pm.setProperty("withjmx", "yes"); jrds.Configuration.configure(pm); jrds.JrdsLoggerConfiguration.configure(jrds.Configuration.get().getPropertiesManager()); if(jrds.Configuration.get().getPropertiesManager().withjmx) { doJmx(jrds.Configuration.get().getPropertiesManager()); Management.register(propFile); } // Make it wait on himself to wait forever try { Thread.currentThread().join(); System.out.print("joined"); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
static public void configure() throws IOException { Locale.setDefault(new Locale("POSIX")); System.getProperties().setProperty("java.awt.headless", "true"); LogManager.resetConfiguration(); // resetConfiguration is not enough @SuppressWarnings("unchecked") List<Logger> loggers = (List<Logger>) Collections.list(LogManager.getCurrentLoggers()); for(Logger l: loggers) { l.removeAllAppenders(); l.setLevel(Level.OFF); } JrdsLoggerConfiguration.jrdsAppender = new ConsoleAppender(new org.apache.log4j.PatternLayout(JrdsLoggerConfiguration.DEFAULTLAYOUT), ConsoleAppender.SYSTEM_OUT); JrdsLoggerConfiguration.jrdsAppender.setName(JrdsLoggerConfiguration.APPENDERNAME); JrdsLoggerConfiguration.initLog4J(); }
public static void main(String[] args) throws Exception { jrds.JrdsLoggerConfiguration.initLog4J();
@Test public void testOutsideConfiguration() throws IOException { LogManager.getLoggerRepository().resetConfiguration(); ta.setName(TANAME); JrdsLoggerConfiguration.jrdsAppender = ta; Logger.getRootLogger().addAppender(ta); JrdsLoggerConfiguration.initLog4J(); Assert.assertNotNull(LogManager.getLoggerRepository().exists("jrds")); PropertiesManager pm = Tools.makePm(testFolder, "loglevel=error"); JrdsLoggerConfiguration.configure(pm); Logger l = Logger.getLogger("jrds"); l.error("A message"); l.debug("A debug message"); Assert.assertEquals(2, logs.size()); }
@Test public void testConfiguration() throws IOException { LogManager.getLoggerRepository().resetConfiguration(); JrdsLoggerConfiguration.initLog4J(); Logger jrdsLogger = LogManager.getLoggerRepository().exists("jrds"); Assert.assertNotNull(jrdsLogger); PropertiesManager pm = Tools.makePm(testFolder, "loglevel=warn"); JrdsLoggerConfiguration.configure(pm); Assert.assertEquals(pm.loglevel, jrdsLogger.getLevel()); }