List of usage examples for java.util.logging Handler getLevel
public Level getLevel()
From source file:processing.app.Base.java
static public void initLogger() { Handler consoleHandler = new ConsoleLogger(); consoleHandler.setLevel(Level.ALL); consoleHandler.setFormatter(new LogFormatter("%1$tl:%1$tM:%1$tS [%4$7s] %2$s: %5$s%n")); Logger globalLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); globalLogger.setLevel(consoleHandler.getLevel()); // Remove default Handler[] handlers = globalLogger.getHandlers(); for (Handler handler : handlers) { globalLogger.removeHandler(handler); }/*w w w.j a v a 2s. co m*/ Logger root = Logger.getLogger(""); handlers = root.getHandlers(); for (Handler handler : handlers) { root.removeHandler(handler); } globalLogger.addHandler(consoleHandler); Logger.getLogger("cc.arduino.packages.autocomplete").setParent(globalLogger); Logger.getLogger("br.com.criativasoft.cpluslibparser").setParent(globalLogger); Logger.getLogger(Base.class.getPackage().getName()).setParent(globalLogger); }
From source file:tiemens.util.instancer.antlr.InstancerCode.java
/** * If loggingConfigureString is NOT UPPER CASE, * Then//from w w w. ja v a 2 s . co m * If uselogger's handler(s) are examined and changed if they * would not log at 'newLevel' * * @param newLevel the parsed loggingConfigureString * @param uselogger whose handler(s) we change * @param loggingConfigureString original configuration string */ private void updateHandlers(Level newLevel, Logger uselogger, String loggingConfigureString) { List<Handler> handlers = new ArrayList<Handler>(); Logger walk = uselogger; while (walk != null) { for (Handler add : walk.getHandlers()) { handlers.add(add); } walk = walk.getParent(); } for (Handler handler : handlers) { metaLoggerInfo( "Handler level = " + handler.getLevel().intValue() + "newLevel = " + newLevel.intValue()); if (handler.getLevel().intValue() > newLevel.intValue()) { if (!loggingConfigureString.equals(loggingConfigureString.toUpperCase())) { String note = "Note: setting handler level to '" + loggingConfigureString + "'."; String explain = "Use '" + loggingConfigureString.toUpperCase() + "' to prevent this behavior."; String msg = "Instancer: " + note + " " + explain; metaLoggerInfo(msg); logger.info(msg); handler.setLevel(newLevel); } } } }