List of usage examples for java.util.logging Level parse
public static synchronized Level parse(String name) throws IllegalArgumentException
From source file:hudson.logging.LogRecorderManager.java
/** * Renders the given log recorders as RSS. *//*from w ww . j a v a 2s.co m*/ /*package*/ static void doRss(StaplerRequest req, StaplerResponse rsp, List<LogRecord> logs) throws IOException, ServletException { // filter log records based on the log level String level = req.getParameter("level"); if (level != null) { Level threshold = Level.parse(level); List<LogRecord> filtered = new ArrayList<LogRecord>(); for (LogRecord r : logs) { if (r.getLevel().intValue() >= threshold.intValue()) filtered.add(r); } logs = filtered; } RSS.forwardToRss("Hudson log", "", logs, new FeedAdapter<LogRecord>() { public String getEntryTitle(LogRecord entry) { return entry.getMessage(); } public String getEntryUrl(LogRecord entry) { return "log"; // TODO: one URL for one log entry? } public String getEntryID(LogRecord entry) { return String.valueOf(entry.getSequenceNumber()); } public String getEntryDescription(LogRecord entry) { return Functions.printLogRecord(entry); } public Calendar getEntryTimestamp(LogRecord entry) { GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(entry.getMillis()); return cal; } public String getEntryAuthor(LogRecord entry) { return Mailer.descriptor().getAdminAddress(); } }, req, rsp); }
From source file:hudson.logging.LogRecorderManager.java
/** * Configure the logging level.//www . jav a 2s . c o m */ public HttpResponse doConfigLogger(@QueryParameter String name, @QueryParameter String level) { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); Level lv; if (level.equals("inherit")) lv = null; else lv = Level.parse(level.toUpperCase()); Logger.getLogger(name).setLevel(lv); return new HttpRedirect("all"); }
From source file:edu.usu.sdl.openstorefront.web.action.admin.LoggingAction.java
@HandlesEvent("UpdateHandlerLevel") public Resolution updateHandlerLevel() { Logger localLogger = LogManager.getLogManager().getLogger(logger); if (localLogger != null) { for (Handler handlerLocal : localLogger.getHandlers()) { if (handlerLocal.getClass().getName().equals(handler)) { if (StringUtils.isNotBlank(level)) { handlerLocal.setLevel(Level.parse(level)); } else { handlerLocal.setLevel(null); }/*from w w w . j av a 2 s .c om*/ } } log.log(Level.INFO, SecurityUtil.adminAuditLogMessage(getContext().getRequest())); } else { throw new OpenStorefrontRuntimeException("Unable to find logger", "Check name"); } return viewLoggers(); }
From source file:com.jmstoolkit.logging.JTKHandler.java
/** * * @param newLevel logging level//from w w w. ja v a2 s. c om */ @ManagedAttribute public final void setLevelName(final String newLevel) { super.setLevel(Level.parse(newLevel.toUpperCase(Locale.getDefault()))); }
From source file:org.apache.nutch.api.NutchServer.java
/** * Public constructor which accepts the port we wish to run the server on as * well as the logging granularity. If the latter option is not provided via * {@link org.apache.nutch.api.NutchServer#main(String[])} then it defaults to * 'INFO' however best attempts should always be made to specify a logging * level./*from w ww. j a v a 2 s . co m*/ */ public NutchServer() { configManager = new RAMConfManager(); BlockingQueue<Runnable> runnables = Queues.newArrayBlockingQueue(JOB_CAPACITY); NutchServerPoolExecutor executor = new NutchServerPoolExecutor(10, JOB_CAPACITY, 1, TimeUnit.HOURS, runnables); jobMgr = new RAMJobManager(new JobFactory(), executor, configManager); // Create a new Component. component = new Component(); component.getLogger().setLevel(Level.parse(logLevel)); // Add a new HTTP server listening on defined port. component.getServers().add(Protocol.HTTP, port); Context childContext = component.getContext().createChildContext(); JaxRsApplication application = new JaxRsApplication(childContext); application.add(this); application.setStatusService(new ErrorStatusService()); childContext.getAttributes().put(NUTCH_SERVER, this); // Attach the application. component.getDefaultHost().attach(application); }
From source file:ffx.Main.java
/** * Replace the default console handler with our custom FFX handler. *//*from w w w . ja v a2 s.c o m*/ private static void startLogging() { // Remove all log handlers from the default logger. try { Logger defaultLogger = LogManager.getLogManager().getLogger(""); Handler defaultHandlers[] = defaultLogger.getHandlers(); for (Handler h : defaultHandlers) { defaultLogger.removeHandler(h); } } catch (Exception e) { System.err.println(e.toString()); } // Retrieve the log level from the ffx.log system property. String logLevel = System.getProperty("ffx.log", "info"); Level tempLevel; try { tempLevel = Level.parse(logLevel.toUpperCase()); } catch (Exception e) { tempLevel = Level.INFO; } level = tempLevel; logHandler = new LogHandler(); logHandler.setLevel(level); Logger ffxLogger = Logger.getLogger("ffx"); ffxLogger.addHandler(logHandler); ffxLogger.setLevel(level); }
From source file:org.nuxeo.runtime.AbstractRuntimeService.java
@Override public synchronized void start() { if (isStarted) { return;//from w w w.j a va 2s .c om } if (Boolean.parseBoolean(getProperty(REDIRECT_JUL, "false"))) { Level threshold = Level.parse(getProperty(REDIRECT_JUL_THRESHOLD, "INFO").toUpperCase()); JavaUtilLoggingHelper.redirectToApacheCommons(threshold); } log.info("Starting Nuxeo Runtime service " + getName() + "; version: " + getVersion()); // NXRuntime.setInstance(this); manager = createComponentManager(); Framework.sendEvent(new RuntimeServiceEvent(RuntimeServiceEvent.RUNTIME_ABOUT_TO_START, this)); ServicePassivator.passivate().withQuietDelay(Duration.ofSeconds(0)).monitor() .withTimeout(Duration.ofSeconds(0)).withEnforceMode(false).await().proceed(() -> { try { doStart(); startExtensions(); } finally { Framework.sendEvent(new RuntimeServiceEvent(RuntimeServiceEvent.RUNTIME_STARTED, this)); isStarted = true; } }); }
From source file:org.construct_infrastructure.component.datastorage.observable.ObservableDataStoreImpl.java
/** * Construct an ObservableDataStore with zero Observers. *//*from w w w . j av a 2 s . co m*/ public ObservableDataStoreImpl() { MY_LOGGER.setLevel(Level.parse(ConstructProperties.getLoggingLevel())); my_observers = new ArrayList(); // Use thread cache my_executor = Executors.newSingleThreadExecutor(); }
From source file:org.freaknet.gtrends.client.GoogleTrendsClientFactory.java
private static void setLogLevel(CmdLineParser cmdLine) throws SecurityException, IllegalArgumentException { final Level level; if (cmdLine.getLogLevel() != null) { level = Level.parse(cmdLine.getLogLevel()); } else {//from w w w.j a v a2s . co m level = Level.parse(DEFAULT_LOGGING_LEVEL); } Logger log = LogManager.getLogManager().getLogger(""); for (Handler h : log.getHandlers()) { log.removeHandler(h); } Handler handler = new ConsoleHandler(); handler.setFormatter(new LogFormatter()); handler.setLevel(level); log.setUseParentHandlers(false); Logger defaultLog = Logger.getLogger(GoogleConfigurator.getLoggerPrefix()); defaultLog.addHandler(handler); defaultLog.setLevel(level); defaultLog.setFilter(new Filter() { @Override public boolean isLoggable(LogRecord record) { if (record.getSourceClassName().startsWith(GoogleConfigurator.getLoggerPrefix())) { return (record.getLevel().intValue() >= level.intValue()); } return false; } }); }
From source file:fr.ens.transcriptome.teolenn.Main.java
/** * Parse the options of the command line * @param args command line arguments//from w w w . j a v a 2 s . co m * @return the number of optional arguments */ private static int parseCommandLine(final String args[]) { final Options options = makeOptions(); final CommandLineParser parser = new GnuParser(); int argsOptions = 0; try { // parse the command line arguments CommandLine line = parser.parse(options, args); if (line.hasOption("help")) help(options); if (line.hasOption("about")) about(); if (line.hasOption("version")) version(); if (line.hasOption("license")) license(); // Load configuration if exists try { if (line.hasOption("conf")) { Settings.loadSettings(new File(line.getOptionValue("conf"))); argsOptions += 2; } else Settings.loadSettings(); } catch (IOException e) { logger.severe("Error while reading configuration file."); System.exit(1); } // Set the number of threads if (line.hasOption("threads")) try { argsOptions += 2; Settings.setMaxthreads(Integer.parseInt(line.getOptionValue("threads"))); } catch (NumberFormatException e) { logger.warning("Invalid threads number"); } // Set the verbose mode for extenal tools if (line.hasOption("verbose")) { Settings.setStandardOutputForExecutable(true); argsOptions++; } // Set Log file if (line.hasOption("log")) { argsOptions += 2; try { Handler fh = new FileHandler(line.getOptionValue("log")); fh.setFormatter(Globals.LOG_FORMATTER); logger.setUseParentHandlers(false); logger.addHandler(fh); } catch (IOException e) { logger.severe("Error while creating log file: " + e.getMessage()); System.exit(1); } } // Set the silent option if (line.hasOption("silent")) logger.setUseParentHandlers(false); // Set log level if (line.hasOption("loglevel")) { argsOptions += 2; try { logger.setLevel(Level.parse(line.getOptionValue("loglevel").toUpperCase())); } catch (IllegalArgumentException e) { logger.warning("Unknown log level (" + line.getOptionValue("loglevel") + "). Accepted values are [SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST]."); } } } catch (ParseException e) { System.err.println(e.getMessage()); System.exit(1); } catch (SecurityException e) { logger.severe(e.getMessage()); System.exit(1); } // If there is no arguments after the option, show help if (argsOptions == args.length) { System.err.println("No inputs files."); System.err.println("type: " + Globals.APP_NAME_LOWER_CASE + " -h for more informations."); System.exit(1); } return argsOptions; }