Package java.util.logging

Examples of java.util.logging.LogManager$Beans


    }
  }

  public static class TestValidConfigFile {
    public static void main(String[] args) {
      LogManager manager = LogManager.getLogManager();
      Logger root = manager.getLogger("");
      checkPropertyNull(manager);
      assertEquals(2, root.getHandlers().length);
      assertEquals(root.getHandlers()[0].getLevel(), Level.OFF);
      assertEquals(Level.ALL, root.getLevel());

      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
      checkPropertyNull(manager);
      assertEquals(root.getHandlers()[0].getLevel(), Level.OFF);
      assertEquals(2, root.getHandlers().length);
      assertEquals(Level.ALL, root.getLevel());

      manager.reset();
      checkPropertyNull(manager);
      assertEquals(0, root.getHandlers().length);
      assertEquals(Level.INFO, root.getLevel());
      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here


    }
  }

  public static class TestMockLogManager {
    public static void main(String[] args) {
      LogManager manager = LogManager.getLogManager();
      assertTrue(manager instanceof MockLogManager);
    }
View Full Code Here

    }
  }

  public static class TestValidConfigClass {
    public static void main(String[] args) {
      LogManager manager = LogManager.getLogManager();
      Logger root = manager.getLogger("");
      checkPropertyNull(manager);
      assertEquals(1, root.getHandlers().length);
      assertEquals(Level.OFF, root.getLevel());

      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
      checkPropertyNull(manager);
      assertEquals(1, root.getHandlers().length);
      assertEquals(Level.OFF, root.getLevel());

      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
      checkPropertyNull(manager);
      assertEquals(1, root.getHandlers().length);
      assertEquals(Level.OFF, root.getLevel());

      manager.reset();
      checkPropertyNull(manager);
      assertEquals(0, root.getHandlers().length);
      assertEquals(Level.INFO, root.getLevel());
      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

      p.put("handlers", className + "$MockHandler");
      p.put(".level", "OFF");
      InputStream in = null;
      try {
        in = EnvironmentHelper.PropertiesToInputStream(p);
        LogManager manager = LogManager.getLogManager();
        manager.readConfiguration(in);
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        try {
          in.close();
View Full Code Here

  }

  public static class MockValidConfig {
    public MockValidConfig() {
      handler = new MockHandler();
      LogManager manager = LogManager.getLogManager();
      Logger root = null;
      if (null != manager) {
        root = manager.getLogger("");
      } else {
        System.out.println("null manager");
      }
      if (null != root) {
        root.addHandler(handler);
View Full Code Here

      addNamespaceHandlers();
   }

   private void modifyRootLogger()
   {
      LogManager logManager = LogManager.getLogManager();
      Logger root = logManager.getLogger("");
      while (root.getParent() != null)
         root = root.getParent();

      Handler[] handlers = root.getHandlers();
      for (int i = 0; i < handlers.length; i++)
View Full Code Here

      }
   }

   private void addNamespaceHandlers()
   {
      LogManager logManager = LogManager.getLogManager();
      for (String ns : namespaces)
      {
         JDKLogger log = new JDKLogger(ns);
         log.addHandler(new JDKLogHandler());
         logManager.addLogger(log);
      }
   }
View Full Code Here

    // Ideally, we'd just return LogManager.getLogManager.getOrAddLogger(name)
    // here, since the code is basically the same, except that code gets to call
    // addLoggerWithoutDuplicationChecking, which makes it somewhat more
    // efficient. However, that means adding a public method to LogManager which
    // is not in the API which is frowned upon.
    LogManager manager = LogManager.getLogManager();
    Logger logger = manager.getLogger(name);
    if (logger == null) {
      Logger newLogger = new LoggerWithExposedConstructor(name);
      manager.addLogger(newLogger);
      return newLogger;
    }
    return logger;
  }
View Full Code Here

    }
  }

  public static class TestInvalidConfigFile {
    public static void main(String[] args) {
      LogManager manager = LogManager.getLogManager();
      Logger root = manager.getLogger("");
      checkPropertyNull(manager);
      assertEquals(0, root.getHandlers().length);
      assertEquals(Level.INFO, root.getLevel());

      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
      checkProperty(manager);
      assertNull(root.getHandlers()[0].getLevel());
      assertEquals(1, root.getHandlers().length);
      assertEquals(Level.INFO, root.getLevel());

      manager.reset();
      checkProperty(manager);
      assertEquals(0, root.getHandlers().length);
      assertEquals(Level.INFO, root.getLevel());
      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

    }
  }

  public static class TestValidConfigFile {
    public static void main(String[] args) {
      LogManager manager = LogManager.getLogManager();
      Logger root = manager.getLogger("");
      checkPropertyNull(manager);
      assertEquals(2, root.getHandlers().length);
      assertEquals(root.getHandlers()[0].getLevel(), Level.OFF);
      assertEquals(Level.ALL, root.getLevel());

      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
      checkPropertyNull(manager);
      assertEquals(root.getHandlers()[0].getLevel(), Level.OFF);
      assertEquals(2, root.getHandlers().length);
      assertEquals(Level.ALL, root.getLevel());

      manager.reset();
      checkPropertyNull(manager);
      assertEquals(0, root.getHandlers().length);
      assertEquals(Level.INFO, root.getLevel());
      try {
        manager.readConfiguration();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

TOP

Related Classes of java.util.logging.LogManager$Beans

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.