Level logLevel = logger.getLevel(); String searchName = name; String parentName = parent != null ? parent.getName() : ""; while (logLevel == null && ! searchName.equals(parentName)) { logLevel = getLevelProperty(searchName + ".level", logLevel); int index = searchName.lastIndexOf('.'); if(index > -1) searchName = searchName.substring(0,index); else searchName = ""; } logger.setLevel(logLevel);
  public synchronized boolean addLogger(Logger logger)  {    /* To developers thinking about to remove the 'synchronized'     * declaration from this method: Please read the comment     * in java.util.logging.Logger.getLogger(String, String)     * and make sure that whatever you change wrt. synchronization     * does not endanger thread-safety of Logger.getLogger.     * The current implementation of Logger.getLogger assumes     * that LogManager does its synchronization on the globally     * shared instance of LogManager.     */    String name;    WeakReference  ref;    /* This will throw a NullPointerException if logger is null,     * as required by the API specification.     */    name = logger.getName();    ref = (WeakReference) loggers.get(name);    if (ref != null)    {      if (ref.get() != null)	return false;      /* There has been a logger under this name in the past,       * but it has been garbage collected.       */      loggers.remove(ref);    }    /* Adding a named logger requires a security permission. */    if ((name != null) && ! name.equals(""))      checkAccess();    Logger parent = findAncestor(logger);    loggers.put(name, new WeakReference(logger));    if (parent != logger.getParent())      logger.setParent(parent);    /* It can happen that existing loggers should be children of     * the newly added logger. For example, assume that there     * already exist loggers under the names "", "foo", and "foo.bar.baz".     * When adding "foo.bar", the logger "foo.bar.baz" should change     * its parent to "foo.bar".     */    if (parent != rootLogger)    {      for (Iterator iter = loggers.keySet().iterator(); iter.hasNext();)      {	    Logger possChild = (Logger) ((WeakReference) loggers.get(iter.next()))	                       .get();	    if ((possChild == null) || (possChild == logger)	        || (possChild.getParent() != parent))	  continue;	    if (! possChild.getName().startsWith(name))	  continue;	if (possChild.getName().charAt(name.length()) != '.')	  continue;	possChild.setParent(logger);      }    }    return true;  }