Package java.util.logging

Examples of java.util.logging.LogManager


    @AfterClass
    public static void afterClass() throws Exception {
        if (server != null) {
            server.destroy();
        }
        LogManager lm = LogManager.getLogManager();
        try {
            // restoring original configuration to not use tested logging handlers
            lm.readConfiguration();
        } catch (Exception e) {
            // ignore missing config file
        }
    }
View Full Code Here


public class ConsoleHandlerStdout extends Handler
{

    private void configure()
    {
        LogManager manager = LogManager.getLogManager();
        String cname = getClass().getName();
       
        String cls = manager.getProperty(cname+".formatter") ;
        Formatter fmt = null ;
       
        try {
            if (cls != null) {
                Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cls);
View Full Code Here

        Timestamp ts = new Timestamp(System.currentTimeMillis());
        String tsString = ts.toString().substring(0, 19);
        date = tsString.substring(0, 10);

        LogManager manager = LogManager.getLogManager();
        String className = FileHandler.class.getName();
       
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
       
        // Retrieve configuration of logging file name
View Full Code Here

final class LoggerProviders {
    static final LoggerProvider PROVIDER = findProvider();

    private static LoggerProvider findProvider() {
        final LogManager jdkLogManager = LogManager.getLogManager();
        final ClassLoader cl = getClassLoader();
        try {
           if (jdkLogManager.getClass().getName().equals("org.jboss.logmanager.LogManager")) {
              return (LoggerProvider) Class.forName("org.jboss.logging.JBossLogManagerProvider", true, cl).newInstance();
           }
        } catch (Throwable t) {
           // nope...
        }
View Full Code Here

    // delete file if it exists
    this.logFile.delete();

    // initialize log framework
    LogManager logManager = LogManager.getLogManager();
    try {
      InputStream ins = ClassLoader.getSystemResourceAsStream(loggerPropertiesFileName);
      // Try the current class loader if system one cannot find the file
      if (ins == null) {
      ins = this.getClass().getClassLoader().getResourceAsStream(loggerPropertiesFileName);
      }
      if (ins != null) {
      logManager.readConfiguration(ins);
      } else {
      System.out.println("WARNING: failed to load "+loggerPropertiesFileName);
      }
    } catch (SecurityException e) {
      handleException(e);
View Full Code Here

  public void test_addLoggerLLogger_Security() throws Exception {
    // regression test for Harmony-1286
    SecurityManager originalSecurityManager = System.getSecurityManager();
    System.setSecurityManager(new SecurityManager());
    try {
      LogManager manager = LogManager.getLogManager();
      manager.addLogger(new MockLogger("mock", null));
      manager.addLogger(new MockLogger("mock.child", null));
    } finally {
      System.setSecurityManager(originalSecurityManager);
    }
  }
View Full Code Here

     * mock classes
   * ----------------------------------------------------
   */
    public static class ConfigClass {
        public ConfigClass() throws Exception{
            LogManager man = LogManager.getLogManager();
            Properties props = LogManagerTest.initProps();
            props.put("testConfigClass.foo.level", "OFF");
            props.put("testConfigClass.foo.handlers", "java.util.logging.ConsoleHandler");       
            props.put(".level", "FINEST");
            props.remove("handlers");
            InputStream in = EnvironmentHelper.PropertiesToInputStream(props);
            man.readConfiguration(in);
        }
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

    }
  }

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

TOP

Related Classes of java.util.logging.LogManager

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.