Package java.util.logging

Examples of java.util.logging.LoggingMXBean


  public void test(TestHarness h)
  {
    try
      {
  Exception caught = null;
  LoggingMXBean bean = LogManager.getLoggingMXBean();

  tsm.install();

  // Check setLoggerLevel
        caught = null;
        try
          {
            bean.setLoggerLevel("global", null);
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "loggerLevel");
        try
          {
            bean.setLoggerLevel("NotALogger", null);
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof IllegalArgumentException, "loggerLevel");
        try
          {
            bean.setLoggerLevel(null, null);
          }
        catch (Exception ex)
          {
            caught = ex;
          }
View Full Code Here


        super.tearDown();
    }

    public final void testIsSingleton() {
        // Verify we always get the same instance
        LoggingMXBean bean = ManagementUtils.getLoggingBean();
        assertSame(mb, bean);
    }
View Full Code Here

    private final String ANON_LOGGER  = "anonymous";

    public String getLoggingReport() throws RuntimeException {
        try {
           StringBuilderNewLineAppender sb = new StringBuilderNewLineAppender(new StringBuilder());
            LoggingMXBean lb = LogManager.getLoggingMXBean();
            List<String> loggers = lb.getLoggerNames();
            Collections.sort(loggers);
            String lf = System.getProperty("java.util.logging.config.file");
            sb.append(sm.getString("logging.config.file", lf));
            sb.append(sm.getString("reg.loggers", loggers.size()));
            sb.append(sm.getString("logger.details.1"));
            sb.append(sm.getString("logger.details.2"));
            sb.append(sm.getString("list.of.loggers"));
            sb.append("--------------------------------------------------");
            for (String logger : loggers) {
                String ln = (logger == null) ? ANON_LOGGER : logger;
                String parent = lb.getParentLoggerName(logger);
                if (parent == null || parent.length() == 0)
                    parent = ROOT_LOGGER;
                sb.append(ln + "|" + lb.getLoggerLevel(logger) + "|" + parent);
            }
            return (sb.toString());
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here

TOP

Related Classes of java.util.logging.LoggingMXBean

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.