当前位置: 首页>>代码示例>>Java>>正文


Java HierarchyDynamicMBean类代码示例

本文整理汇总了Java中org.apache.log4j.jmx.HierarchyDynamicMBean的典型用法代码示例。如果您正苦于以下问题:Java HierarchyDynamicMBean类的具体用法?Java HierarchyDynamicMBean怎么用?Java HierarchyDynamicMBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HierarchyDynamicMBean类属于org.apache.log4j.jmx包,在下文中一共展示了HierarchyDynamicMBean类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerLog4jMBeans

import org.apache.log4j.jmx.HierarchyDynamicMBean; //导入依赖的package包/类
/**
 * Register the log4j JMX mbeans. Set environment variable
 * "zookeeper.jmx.log4j.disable" to true to disable registration.
 * @see http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/jmx/package-summary.html
 * @throws JMException if registration fails
 */
public static void registerLog4jMBeans() throws JMException {
    if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
        return;
    }
    
    MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();

    // Create and Register the top level Log4J MBean
    HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();

    ObjectName mbo = new ObjectName("log4j:hiearchy=default");
    mbs.registerMBean(hdm, mbo);

    // Add the root logger to the Hierarchy MBean
    Logger rootLogger = Logger.getRootLogger();
    hdm.addLoggerMBean(rootLogger.getName());

    // Get each logger from the Log4J Repository and add it to
    // the Hierarchy MBean created above.
    LoggerRepository r = LogManager.getLoggerRepository();
    Enumeration enumer = r.getCurrentLoggers();
    Logger logger = null;

    while (enumer.hasMoreElements()) {
       logger = (Logger) enumer.nextElement();
       hdm.addLoggerMBean(logger.getName());
    }
}
 
开发者ID:jdc91,项目名称:StreamProcessingInfrastructure,代码行数:35,代码来源:ManagedUtil.java

示例2: registerLog4jMBeans

import org.apache.log4j.jmx.HierarchyDynamicMBean; //导入依赖的package包/类
/**
 * Register the log4j JMX mbeans. Set environment variable
 * "zookeeper.jmx.log4j.disable" to true to disable registration.
 * @see http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/jmx/package-summary.html
 * @throws JMException if registration fails
 */
public static void registerLog4jMBeans() throws JMException {
    if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
        return;
    }
    
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    // Create and Register the top level Log4J MBean
    HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();

    ObjectName mbo = new ObjectName("log4j:hiearchy=default");
    mbs.registerMBean(hdm, mbo);

    // Add the root logger to the Hierarchy MBean
    Logger rootLogger = Logger.getRootLogger();
    hdm.addLoggerMBean(rootLogger.getName());

    // Get each logger from the Log4J Repository and add it to
    // the Hierarchy MBean created above.
    LoggerRepository r = LogManager.getLoggerRepository();
    Enumeration enumer = r.getCurrentLoggers();
    Logger logger = null;

    while (enumer.hasMoreElements()) {
       logger = (Logger) enumer.nextElement();
       hdm.addLoggerMBean(logger.getName());
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:35,代码来源:ManagedUtil.java

示例3: registerLog4jMBeans

import org.apache.log4j.jmx.HierarchyDynamicMBean; //导入依赖的package包/类
/**
 * Register the log4j JMX mbeans. Set environment variable
 * "zookeeper.jmx.log4j.disable" to true to disable registration.
 * @see http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/jmx/package-summary.html
 * @throws JMException if registration fails
 */
public static void registerLog4jMBeans() throws JMException {
    if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
        return;
    }

    MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();

    // Create and Register the top level Log4J MBean
    HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();

    ObjectName mbo = new ObjectName("log4j:hiearchy=default");
    mbs.registerMBean(hdm, mbo);

    // Add the root logger to the Hierarchy MBean
    Logger rootLogger = Logger.getRootLogger();
    hdm.addLoggerMBean(rootLogger.getName());

    // Get each logger from the Log4J Repository and add it to
    // the Hierarchy MBean created above.
    LoggerRepository r = LogManager.getLoggerRepository();
    Enumeration enumer = r.getCurrentLoggers();
    Logger logger = null;

    while (enumer.hasMoreElements()) {
        logger = (Logger) enumer.nextElement();
        hdm.addLoggerMBean(logger.getName());
    }
}
 
开发者ID:blentle,项目名称:zookeeper-src-learning,代码行数:35,代码来源:ManagedUtil.java

示例4: registerLog4jMBeans

import org.apache.log4j.jmx.HierarchyDynamicMBean; //导入依赖的package包/类
/**
 * Register the log4j JMX mbeans. Set environment variable
 * "zookeeper.jmx.log4j.disable" to true to disable registration.
 * @see http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/jmx/package-summary.html
 * @throws JMException if registration fails
 */
public static void registerLog4jMBeans() throws JMException {
    // 设置zookeeper.jmx.log4j.disable=true, 禁用注册Log4j的MBean
    if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
        return;
    }
    
    MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();

    // Create and Register the top level Log4J MBean
    HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();

    ObjectName mbo = new ObjectName("log4j:hiearchy=default");
    mbs.registerMBean(hdm, mbo);

    // Add the root logger to the Hierarchy MBean
    Logger rootLogger = Logger.getRootLogger();
    hdm.addLoggerMBean(rootLogger.getName());

    // Get each logger from the Log4J Repository and add it to
    // the Hierarchy MBean created above.
    LoggerRepository r = LogManager.getLoggerRepository();
    Enumeration enumer = r.getCurrentLoggers();
    Logger logger = null;

    while (enumer.hasMoreElements()) {
       logger = (Logger) enumer.nextElement();
       hdm.addLoggerMBean(logger.getName());
    }
}
 
开发者ID:txazo,项目名称:zookeeper,代码行数:36,代码来源:ManagedUtil.java

示例5: configureMBeanServer

import org.apache.log4j.jmx.HierarchyDynamicMBean; //导入依赖的package包/类
private void configureMBeanServer() {
  logger.info("Registering MBeans...");
  mbeanServer = ManagementFactory.getPlatformMBeanServer();

  registerMbean("jetty", new JmxJettyServer(server));
  registerMbean("triggerManager", new JmxTriggerManager(triggerManager));
  if (executorManager instanceof ExecutorManager) {
    registerMbean("executorManager", new JmxExecutorManager(
        (ExecutorManager) executorManager));
  }

  // Register Log4J loggers as JMX beans so the log level can be
  // updated via JConsole or Java VisualVM
  HierarchyDynamicMBean log4jMBean = new HierarchyDynamicMBean();
  registerMbean("log4jmxbean", log4jMBean);
  ObjectName accessLogLoggerObjName =
      log4jMBean.addLoggerMBean(AZKABAN_ACCESS_LOGGER_NAME);

  if (accessLogLoggerObjName == null) {
    System.out
        .println("************* loginLoggerObjName is null, make sure there is a logger with name "
            + AZKABAN_ACCESS_LOGGER_NAME);
  } else {
    System.out.println("******** loginLoggerObjName: "
        + accessLogLoggerObjName.getCanonicalName());
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:28,代码来源:AzkabanWebServer.java

示例6: registerLog4jInJmx

import org.apache.log4j.jmx.HierarchyDynamicMBean; //导入依赖的package包/类
/**
 * Register Log4J in JMX to allow dynamic configuration
 * of server logging using JMX client (e.g. jconsole).
 */
@SuppressWarnings("unchecked")
public static void registerLog4jInJmx()
{
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();  
    try {
        // Create and Register the top level Log4J MBean
        HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
        ObjectName mbo = new ObjectName("log4j:hiearchy=default");
        mbs.registerMBean(hdm, mbo);

        // Add the root logger to the Hierarchy MBean
        org.apache.log4j.Logger rootLogger =
        	org.apache.log4j.Logger.getRootLogger();
        hdm.addLoggerMBean(rootLogger.getName());

        // Get each logger from the Log4J Repository and add it to
        // the Hierarchy MBean created above.
        LoggerRepository r = LogManager.getLoggerRepository();
        Enumeration<Logger> loggers = r.getCurrentLoggers();
        if (loggers != null) {
            while (loggers.hasMoreElements()) {
            	org.apache.log4j.Logger logger = 
            		(org.apache.log4j.Logger) loggers.nextElement();
                hdm.addLoggerMBean(logger.getName());
            }
        }
    }
    catch (Exception ex) {
        log.error("Failure registering Log4J in JMX: " + ex);
    }
}
 
开发者ID:jagornet,项目名称:dhcp,代码行数:36,代码来源:JagornetDhcpServer.java


注:本文中的org.apache.log4j.jmx.HierarchyDynamicMBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。