List of usage examples for java.util.logging LoggingMXBean getLoggerNames
public java.util.List<String> getLoggerNames();
From source file:com.twitter.common.net.http.handlers.LogConfig.java
protected void displayPage(final HttpServletRequest req, HttpServletResponse resp, final boolean posted) throws ServletException, IOException { writeTemplate(resp, new Closure<StringTemplate>() { @Override/*from ww w . j ava 2 s. c o m*/ public void execute(StringTemplate stringTemplate) { LoggingMXBean logBean = LogManager.getLoggingMXBean(); if (posted) { String loggerName = req.getParameter("logger"); String loggerLevel = req.getParameter("level"); if (loggerName != null && loggerLevel != null) { Logger logger = Logger.getLogger(loggerName); Level newLevel = loggerLevel.equals("INHERIT") ? null : Level.parse(loggerLevel); logger.setLevel(newLevel); if (newLevel != null) { maybeAdjustHandlerLevels(logger, newLevel); } stringTemplate.setAttribute("configChange", String.format("%s level changed to %s", loggerName, loggerLevel)); } } List<LoggerConfig> loggerConfigs = Lists.newArrayList(); for (String logger : Ordering.natural().immutableSortedCopy(logBean.getLoggerNames())) { loggerConfigs.add(new LoggerConfig(logger, logBean.getLoggerLevel(logger))); } stringTemplate.setAttribute("loggers", loggerConfigs); stringTemplate.setAttribute("levels", LOG_LEVELS); } }); }
From source file:org.apache.aurora.common.net.http.handlers.LogConfig.java
protected String displayPage(Optional<String> configChange) throws TemplateException { StringWriter writer = new StringWriter(); template.writeTemplate(writer, new Closure<StringTemplate>() { @Override//ww w . j a v a 2 s .c o m public void execute(StringTemplate stringTemplate) { LoggingMXBean logBean = LogManager.getLoggingMXBean(); if (configChange.isPresent()) { stringTemplate.setAttribute("configChange", configChange.get()); } List<LoggerConfig> loggerConfigs = Lists.newArrayList(); for (String logger : Ordering.natural().immutableSortedCopy(logBean.getLoggerNames())) { loggerConfigs.add(new LoggerConfig(logger, logBean.getLoggerLevel(logger))); } stringTemplate.setAttribute("loggers", loggerConfigs); stringTemplate.setAttribute("levels", LOG_LEVELS); } }); return writer.toString(); }