java类org.apache.log4j.jmx.HierarchyDynamicMBean的实例源码

ManagedUtil.java 文件源码 项目:StreamProcessingInfrastructure 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:bigstreams 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:bigstreams 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:zookeeper-src-learning 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:zookeeper 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
AzkabanWebServer.java 文件源码 项目:azkaban 阅读 24 收藏 0 点赞 0 评论 0
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());
  }
}
ManagedUtil.java 文件源码 项目:SecureKeeper 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:SecureKeeper 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:VoltDB 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:StreamBench 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:ACaZoo 阅读 17 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
JagornetDhcpServer.java 文件源码 项目:dhcp 阅读 40 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
ManagedUtil.java 文件源码 项目:LoadBalanced_zk 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:LoadBalanced_zk 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:zookeeper.dsc 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ManagedUtil.java 文件源码 项目:zookeeper-pkg 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号