code: private void addHandler(Handler handler, ClassLoader loader)
    {
      // handlers ordered by level
      ArrayList<Handler> handlers = new ArrayList<Handler>();
  
      handlers.add(handler);
  
      for (ClassLoader ptr = loader; ptr != null; ptr = ptr.getParent()) {
        Handler []localHandlers = _localHandlers.getLevel(ptr);
  
        if (localHandlers != null) {
          for (int i = 0; i < localHandlers.length; i++) {
            int p = handlers.indexOf(localHandlers[i]);
  
            if (p < 0) {
              handlers.add(localHandlers[i]);
            }
            else {
              Handler oldHandler = handlers.get(p);
  
              if (localHandlers[i].getLevel().intValue()
                  < oldHandler.getLevel().intValue()) {
                handlers.set(p, localHandlers[i]);
              }
            }
          }
        }
      }
  
      Handler []newHandlers = new Handler[handlers.size()];
      handlers.toArray(newHandlers);
      
      if (loader == _systemClassLoader)
        loader = null;
  
      _localHandlers.set(newHandlers, loader);
    }
docs: Adds a new handler with a given classloader context.