Пример #1
0
 /////////////////////////  non-public below  //////////////////////////////
 static synchronized void setConsoleLevel(Level level) {
   for (Handler h : logger.getHandlers()) {
     if (ConsoleHandler.class.isAssignableFrom(h.getClass())) {
       h.setLevel(level);
     }
   }
 }
Пример #2
0
  public Level setLevel(final String iLevel, final Class<? extends Handler> iHandler) {
    final Level level =
        iLevel != null ? Level.parse(iLevel.toUpperCase(Locale.ENGLISH)) : Level.INFO;

    if (level.intValue() < minimumLevel.intValue()) {
      // UPDATE MINIMUM LEVEL
      minimumLevel = level;

      if (level.equals(Level.FINER) || level.equals(Level.FINE) || level.equals(Level.FINEST))
        debug = info = warn = error = true;
      else if (level.equals(Level.INFO)) {
        info = warn = error = true;
        debug = false;
      } else if (level.equals(Level.WARNING)) {
        warn = error = true;
        debug = info = false;
      } else if (level.equals(Level.SEVERE)) {
        error = true;
        debug = info = warn = false;
      }
    }

    Logger log = Logger.getLogger(DEFAULT_LOG);
    while (log != null) {
      log.setLevel(level);

      for (Handler h : log.getHandlers()) {
        if (h.getClass().isAssignableFrom(iHandler)) {
          h.setLevel(level);
          break;
        }
      }

      log = log.getParent();
    }

    return level;
  }