Package org.apache.log4j

Examples of org.apache.log4j.PropertyConfigurator


    if(genericHierarchy == null) {
      File f = new File(dir, GENERIC+CONFIG_FILE_EXT);
      if(f.exists()) {
  genericHierarchy = new Hierarchy(new RootCategory(Priority.DEBUG));
  try {
    new PropertyConfigurator().doConfigure(f.toURL(),
                 genericHierarchy);
  } catch(MalformedURLException e) {
    cat.error("Could not convert"+f
        +" to a URL. Reverting to default hierarchy", e);   
    genericHierarchy = Category.getDefaultHierarchy();
View Full Code Here


        // Check thr file name
        String filename = url.getFile().toLowerCase();
        if (filename.endsWith(".xml")) {
            return new DOMConfigurator();
        } else if (filename.endsWith(".properties")) {
            return new PropertyConfigurator();
        }

        // Check for <?xml in content
        if (connection != null) {
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                try {
                    String head = reader.readLine();
                    if (head.startsWith("<?xml")) {
                        return new DOMConfigurator();
                    }
                } finally {
                    reader.close();
                }
            } catch (IOException e) {
                log.warn("Failed to check content header; ignoring", e);
            }
        }

        log.warn("Unable to determine content type, using property configurator");
        return new PropertyConfigurator();
    }
View Full Code Here

        // Check thr file name
        String filename = url.getFile().toLowerCase();
        if (filename.endsWith(".xml")) {
            return new DOMConfigurator();
        } else if (filename.endsWith(".properties")) {
            return new PropertyConfigurator();
        }

        // Check for <?xml in content
        if (connection != null) {
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                try {
                    String head = reader.readLine();
                    if (head.startsWith("<?xml")) {
                        return new DOMConfigurator();
                    }
                } finally {
                    reader.close();
                }
            } catch (IOException e) {
                log.warn("Failed to check content header; ignoring", e);
            }
        }

        log.warn("Unable to determine content type, using property configurator");
        return new PropertyConfigurator();
    }
View Full Code Here

     if(configurator == null) {
       LogLog.error("Could not instantiate configurator ["+clazz+"].");
       return;
     }
   } else {
     configurator = new PropertyConfigurator();
   }

   configurator.doConfigure(url, hierarchy);
  }
View Full Code Here

     if(configurator == null) {
       LogLog.error("Could not instantiate configurator ["+clazz+"].");
       return;
     }
   } else {
     configurator = new PropertyConfigurator();
   }

   configurator.doConfigure(url, hierarchy);
  }
View Full Code Here

    @AfterClass public static void afterClassResetLogging() {
        // Unfortunately, this code "knows" how log4j was set up in testing
        // Thsi is fragile.
        URL configURL = Loader.getResource("log4j.properties");
        new PropertyConfigurator().doConfigure(configURL,
                                               LogManager.getLoggerRepository());
    }
View Full Code Here

                {
                    waRootKey = LOG4J_CONFIG_WEB_APPLICATION_ROOT_KEY_DEFAULT;
                }
                p.setProperty(waRootKey,rootPath);
                isolatedHierarchy = new Hierarchy(new RootCategory(Level.INFO));
                new PropertyConfigurator().doConfigure(p,isolatedHierarchy);
                IsolatedLog4JLogger.setHierarchy(isolatedHierarchy);
                log = LogFactory.getLog(this.getClass());
                log.info("IsolatedLog4JLogger configured");
            }
            catch (IOException ioe)
View Full Code Here

  } catch(NoClassDefFoundError e) {
    LogLog.warn("Could not find DOMConfigurator!", e);
    return;
  }
      } else {
  configurator = new PropertyConfigurator();
      }
    }

    configurator.doConfigure(url, hierarchy);
  }
View Full Code Here

      File configFile = new File(dir, key+CONFIG_FILE_EXT);
      if(configFile.exists()) {
  Hierarchy h = new Hierarchy(new RootCategory(Priority.DEBUG));
  hierarchyMap.put(inetAddress, h);
 
  new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h);

  return h; 
      } else {
  cat.warn("Could not find config file ["+configFile+"].");
  return genericHierarchy();
View Full Code Here

  Hierarchy genericHierarchy() {
    if(genericHierarchy == null) {
      File f = new File(dir, GENERIC+CONFIG_FILE_EXT);
      if(f.exists()) {
  genericHierarchy = new Hierarchy(new RootCategory(Priority.DEBUG));
  new PropertyConfigurator().doConfigure(f.getAbsolutePath(), genericHierarchy);
      } else {
  cat.warn("Could not find config file ["+f+
     "]. Will use the default hierarchy.");
  genericHierarchy = Category.getDefaultHierarchy();
      }
View Full Code Here

TOP

Related Classes of org.apache.log4j.PropertyConfigurator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.