Package org.apache.log4j

Examples of org.apache.log4j.Hierarchy


    } else {
      String key = s.substring(0, i);
     
      File configFile = new File(dir, key+CONFIG_FILE_EXT);
      if(configFile.exists()) {
  Hierarchy h = new Hierarchy(new RootCategory(Priority.DEBUG));
  hierarchyMap.put(inetAddress, h);
 
  try {
    new PropertyConfigurator().doConfigure(configFile.toURL(), h);
  } catch(MalformedURLException e) {
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));
  try {
    new PropertyConfigurator().doConfigure(f.toURL(),
                 genericHierarchy);
  } catch(MalformedURLException e) {
    cat.error("Could not convert"+f
View Full Code Here

                if ( waRootKey == null || waRootKey.length() == 0 )
                {
                    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");
            }
View Full Code Here

  cat.info("Waiting to accept a new client.");
  Socket socket = serverSocket.accept();
  InetAddress inetAddress =  socket.getInetAddress();
  cat.info("Connected to client at " + inetAddress);

  Hierarchy h = (Hierarchy) server.hierarchyMap.get(inetAddress);
  if(h == null) {
    h = server.configureHierarchy(inetAddress);
  }

  cat.info("Starting new socket node.")
View Full Code Here

    } else {
      String key = s.substring(0, i);
     
      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; 
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

  void testDisable1() {
    CountingAppender caRoot = new CountingAppender();
    Category root = Category.getRoot();   
    root.addAppender(caRoot);

    Hierarchy h = Category.getDefaultHierarchy();
    h.disableDebug();
    assertEquals(caRoot.counter, 0);    

    root.debug(MSG); assertEquals(caRoot.counter, 0)
    root.info(MSG); assertEquals(caRoot.counter, 1)
    root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 2)
    root.warn(MSG); assertEquals(caRoot.counter, 3)

    h.disableInfo();
    root.debug(MSG); assertEquals(caRoot.counter, 3)
    root.info(MSG); assertEquals(caRoot.counter, 3)
    root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 4)
    root.error(MSG); assertEquals(caRoot.counter, 5)
    root.log(Priority.ERROR, MSG); assertEquals(caRoot.counter, 6)

    h.disableAll();
    root.debug(MSG); assertEquals(caRoot.counter, 6)
    root.info(MSG); assertEquals(caRoot.counter, 6)
    root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 6)
    root.error(MSG); assertEquals(caRoot.counter, 6)
    root.log(Priority.FATAL, MSG); assertEquals(caRoot.counter, 6)
    root.log(Priority.FATAL, MSG); assertEquals(caRoot.counter, 6)

    h.disable(Priority.FATAL);
    root.debug(MSG); assertEquals(caRoot.counter, 6)
    root.info(MSG); assertEquals(caRoot.counter, 6)
    root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 6)
    root.error(MSG); assertEquals(caRoot.counter, 6);
    root.log(Priority.ERROR, MSG); assertEquals(caRoot.counter, 6)
View Full Code Here

    t = Category.exists("a.b.c"); assertSame(a_b_c, t);
  }

  public
  void testHierarchy1() {
    Hierarchy h = new Hierarchy( new RootCategory(Priority.ERROR));
    Category a0 = h.getInstance("a");
    assertEquals("a", a0.getName());
    assertNull(a0.getPriority());
    assertSame(Priority.ERROR, a0.getChainedPriority());

    Category a1 = h.getInstance("a");
    assertSame(a0, a1);

   

   
View Full Code Here

     * @param xmlProperties
     *            Needs to be an XML file.
     */
    public PluginLogManager(Plugin plugin, URL xmlProperties) {
        fLog = plugin.getLog();
        fHierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
        fHierarchy.addHierarchyEventListener(new LogListener());
        new DOMConfigurator().doConfigure(xmlProperties, fHierarchy);

        PluginLogManagerRegistry.getInstance().addLogManager(this);
    }
View Full Code Here

     * @param properties
     *            the properties file
     */
    public PluginLogManager(Plugin plugin, Properties properties) {
        fLog = plugin.getLog();
        fHierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
        fHierarchy.addHierarchyEventListener(new LogListener());
        new PropertyConfigurator().doConfigure(properties, fHierarchy);

        PluginLogManagerRegistry.getInstance().addLogManager(this);
    }
View Full Code Here

TOP

Related Classes of org.apache.log4j.Hierarchy

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.