示例#1
0
  LoggerRepository genericHierarchy() {
    if (this.genericHierarchy == null) {
      File f = new File(this.dir, GENERIC + CONFIG_FILE_EXT);
      if (f.exists()) {
        this.genericHierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
        new PropertyConfigurator().doConfigure(f.getAbsolutePath(), this.genericHierarchy);
      } else {
        cat.warn("Could not find config file [" + f + "]. Will use the default hierarchy.");

        this.genericHierarchy = LogManager.getLoggerRepository();
      }
    }
    return this.genericHierarchy;
  }
示例#2
0
  LoggerRepository configureHierarchy(InetAddress inetAddress) {
    cat.info("Locating configuration file for " + inetAddress);

    String s = inetAddress.toString();
    int i = s.indexOf("/");
    if (i == -1) {
      cat.warn("Could not parse the inetAddress [" + inetAddress + "]. Using default hierarchy.");

      return genericHierarchy();
    }
    String key = s.substring(0, i);

    File configFile = new File(this.dir, key + CONFIG_FILE_EXT);
    if (configFile.exists()) {
      Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG));
      this.hierarchyMap.put(inetAddress, h);

      new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h);

      return h;
    }
    cat.warn("Could not find config file [" + configFile + "].");
    return genericHierarchy();
  }