/** * Configures the logging level. * * @param level * The index of the logging level to apply. */ private static void configureLoggingLevel(int logLevelIndex) { Logger rootLogger; rootLogger = Logger.getLogger(""); // Set the required logging level. rootLogger.setLevel(LogLevels.getLogLevel(logLevelIndex)); // Set spring logging to one level lower. Logger.getLogger("org.springframework").setLevel(LogLevels.getLogLevel(logLevelIndex - 1)); // Minimise the JPF logging. Logger.getLogger("org.java.plugin").setLevel(Level.WARNING); } }
/** * Configures the logging level. * * @param level * The index of the logging level to apply. */ private static void configureLoggingLevel(int logLevelIndex) { Logger rootLogger; rootLogger = Logger.getLogger(""); // Set the required logging level. rootLogger.setLevel(LogLevels.getLogLevel(logLevelIndex)); // Set spring logging to one level lower. Logger.getLogger("org.springframework").setLevel(LogLevels.getLogLevel(logLevelIndex - 1)); // Minimise the JPF logging. Logger.getLogger("org.java.plugin").setLevel(Level.WARNING); } }
/** * Validates the quiet option. */ @Test public void testQuietOption() { CommandLineParser commandLineParser; commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {}); Assert.assertEquals("Incorrect default log level.", Level.INFO, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {"-q"}); Assert.assertEquals("Incorrect quiet log level.", Level.WARNING, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {"-q", "1"}); Assert.assertEquals("Incorrect very quiet log level.", Level.SEVERE, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {"-q", "2"}); Assert.assertEquals("Incorrect very very quiet log level.", Level.OFF, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); }
/** * Validates the quiet and verbose options in combination. */ @Test public void testQuietAndVerboseOption() { CommandLineParser commandLineParser; commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {}); Assert.assertEquals("Incorrect default log level.", Level.INFO, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {"-v", "-q"}); Assert.assertEquals("Incorrect default log level.", Level.INFO, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {"-v", "1", "-q", "1"}); Assert.assertEquals("Incorrect default log level.", Level.INFO, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {"-v", "1", "-q", "2"}); Assert.assertEquals("Incorrect quiet log level.", Level.WARNING, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); }
commandLineParser.parse(new String[] {}); Assert.assertEquals("Incorrect default log level.", Level.INFO, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); LogLevels.getLogLevel(commandLineParser.getLogLevelIndex())); "Incorrect very very very verbose log level.", Level.FINEST, LogLevels.getLogLevel(commandLineParser.getLogLevelIndex()));