Package java.util.logging

Examples of java.util.logging.LogManager$LoggerWeakRef


    }
  }

  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

    /*
     * test initHandler
     */
    public void test_initHandler() throws Exception {
        File logProps = new File(LOGGING_CONFIG_FILE);
        LogManager lm = LogManager.getLogManager();
        lm.readConfiguration(new FileInputStream(logProps));

        Logger log = Logger.getLogger("");
        // can log properly
        Handler[] handlers = log.getHandlers();
        assertEquals(2, handlers.length);
View Full Code Here

            }
            finally
            {
                // If JULI is used, shut JULI down *after* the server shuts down
                // so log messages aren't lost
                LogManager logManager = LogManager.getLogManager();
                if ( logManager instanceof ClassLoaderLogManager )
                {
                    ( (ClassLoaderLogManager) logManager ).shutdown();
                }
            }
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

   */
  private final Logger getClosestLogger() {
    if (!_hierarchy)
      return Logger.getLogger(DEFAULT_NAME);

    final LogManager logman = LogManager.getLogManager();
    int j = _name.length();
    do {
      final Logger logger = logman.getLogger(_name.substring(0, j));
      if (logger != null)
        return logger;
      j = _name.lastIndexOf('.', j - 1);
    } while (j >= 0);
    return Logger.getLogger(DEFAULT_NAME);
View Full Code Here

  private Trackbase() {
   
  }
 
  public static void main(String[] args) {
    LogManager lm=LogManager.getLogManager();
    try {
      lm.readConfiguration(Thread.currentThread().getContextClassLoader().getResourceAsStream("log.properties"));
    } catch (IOException ex) {
      System.err.println("failed to configure logging");
    }
    log.info("Starting...");
    Trackbase tb=new Trackbase();
View Full Code Here

                ExceptionUtils.handleThrowable(ex);
                log.error(sm.getString("catalina.shutdownHookFail"), ex);
            } finally {
                // If JULI is used, shut JULI down *after* the server shuts down
                // so log messages aren't lost
                LogManager logManager = LogManager.getLogManager();
                if (logManager instanceof ClassLoaderLogManager) {
                    ((ClassLoaderLogManager) logManager).shutdown();
                }
            }
        }
View Full Code Here

            Runtime.getRuntime().addShutdownHook(shutdownHook);

            // If JULI is being used, disable JULI's shutdown hook since
            // shutdown hooks run in parallel and log messages may be lost
            // if JULI's hook completes before the CatalinaShutdownHook()
            LogManager logManager = LogManager.getLogManager();
            if (logManager instanceof ClassLoaderLogManager) {
                ((ClassLoaderLogManager) logManager).setUseShutdownHook(
                        false);
            }
        }
View Full Code Here

TOP

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

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.