本文整理了Java中org.apache.log4j.jmx.HierarchyDynamicMBean
类的一些代码示例,展示了HierarchyDynamicMBean
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HierarchyDynamicMBean
类的具体详情如下:
包路径:org.apache.log4j.jmx.HierarchyDynamicMBean
类名称:HierarchyDynamicMBean
暂无
代码示例来源:origin: org.apache.zookeeper/zookeeper
/**
* 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
*/
@SuppressWarnings("rawtypes")
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());
}
}
代码示例来源:origin: log4j/log4j
public HierarchyDynamicMBean() {
hierarchy = LogManager.getLoggerRepository();
buildDynamicMBeanInfo();
}
代码示例来源:origin: log4j/log4j
ObjectName addLoggerMBean(Logger logger) {
String name = logger.getName();
ObjectName objectName = null;
try {
LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger);
objectName = new ObjectName("log4j", "logger", name);
if (!server.isRegistered(objectName)) {
registerMBean(loggerMBean, objectName);
NotificationFilterSupport nfs = new NotificationFilterSupport();
nfs.enableType(ADD_APPENDER + logger.getName());
log.debug("---Adding logger [" + name + "] as listener.");
nbs.addNotificationListener(loggerMBean, nfs, null);
vAttributes.add(new MBeanAttributeInfo("logger=" + name, "javax.management.ObjectName",
"The " + name + " logger.", true, true, // this makes the object
// clickable
false));
}
} catch(JMException e) {
log.error("Could not add loggerMBean for ["+name+"].", e);
} catch(RuntimeException e) {
log.error("Could not add loggerMBean for ["+name+"].", e);
}
return objectName;
}
代码示例来源:origin: log4j/log4j
public
ObjectName addLoggerMBean(String name) {
Logger cat = LogManager.exists(name);
if(cat != null) {
return addLoggerMBean(cat);
} else {
return null;
}
}
代码示例来源:origin: log4j/log4j
/**
* Starts instance of HtmlAdapterServer.
* @deprecated
*/
public void start() {
MBeanServer server = MBeanServerFactory.createMBeanServer();
Object html = createServer();
try {
log.info("Registering HtmlAdaptorServer instance.");
server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
log.info("Registering HierarchyDynamicMBean instance.");
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
} catch(JMException e) {
log.error("Problem while registering MBeans instances.", e);
return;
} catch(RuntimeException e) {
log.error("Problem while registering MBeans instances.", e);
return;
}
startServer(html);
}
}
代码示例来源:origin: log4j/log4j
public
void postRegister(java.lang.Boolean registrationDone) {
log.debug("postRegister is called.");
hierarchy.addHierarchyEventListener(this);
Logger root = hierarchy.getRootLogger();
addLoggerMBean(root);
}
代码示例来源:origin: apache/log4j
/**
* Starts instance of HtmlAdapterServer.
* @deprecated
*/
public void start() {
MBeanServer server = MBeanServerFactory.createMBeanServer();
Object html = createServer();
try {
log.info("Registering HtmlAdaptorServer instance.");
server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
log.info("Registering HierarchyDynamicMBean instance.");
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
} catch(JMException e) {
log.error("Problem while registering MBeans instances.", e);
return;
} catch(RuntimeException e) {
log.error("Problem while registering MBeans instances.", e);
return;
}
startServer(html);
}
}
代码示例来源:origin: log4j/log4j
public
Object invoke(String operationName,
Object params[],
String signature[]) throws MBeanException,
ReflectionException {
if (operationName == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException("Operation name cannot be null"),
"Cannot invoke a null operation in " + dClassName);
}
// Check for a recognized operation name and call the corresponding operation
if(operationName.equals("addLoggerMBean")) {
return addLoggerMBean((String)params[0]);
} else {
throw new ReflectionException(
new NoSuchMethodException(operationName),
"Cannot find the operation " + operationName + " in " + dClassName);
}
}
代码示例来源:origin: azkaban/azkaban
private void configureMBeanServer() {
logger.info("Registering MBeans...");
this.mbeanServer = ManagementFactory.getPlatformMBeanServer();
registerMbean("jetty", new JmxJettyServer(this.server));
registerMbean("triggerManager", new JmxTriggerManager(this.triggerManager));
if (this.executorManagerAdapter instanceof ExecutorManager) {
registerMbean("executorManager",
new JmxExecutorManager((ExecutorManager) this.executorManagerAdapter));
} else if (this.executorManagerAdapter instanceof ExecutionController) {
registerMbean("executionController", new JmxExecutionController((ExecutionController) this
.executorManagerAdapter));
}
// Register Log4J loggers as JMX beans so the log level can be
// updated via JConsole or Java VisualVM
final HierarchyDynamicMBean log4jMBean = new HierarchyDynamicMBean();
registerMbean("log4jmxbean", log4jMBean);
final ObjectName accessLogLoggerObjName =
log4jMBean.addLoggerMBean(AZKABAN_ACCESS_LOGGER_NAME);
if (accessLogLoggerObjName == null) {
logger.info(
"************* loginLoggerObjName is null, make sure there is a logger with name "
+ AZKABAN_ACCESS_LOGGER_NAME);
} else {
logger.info("******** loginLoggerObjName: "
+ accessLogLoggerObjName.getCanonicalName());
}
}
代码示例来源:origin: org.apache.activemq/activemq-all
/**
* Starts instance of HtmlAdapterServer.
* @deprecated
*/
public void start() {
MBeanServer server = MBeanServerFactory.createMBeanServer();
Object html = createServer();
try {
log.info("Registering HtmlAdaptorServer instance.");
server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
log.info("Registering HierarchyDynamicMBean instance.");
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
} catch(JMException e) {
log.error("Problem while registering MBeans instances.", e);
return;
} catch(RuntimeException e) {
log.error("Problem while registering MBeans instances.", e);
return;
}
startServer(html);
}
}
代码示例来源:origin: apache/log4j
public HierarchyDynamicMBean() {
hierarchy = LogManager.getLoggerRepository();
buildDynamicMBeanInfo();
}
代码示例来源:origin: apache/log4j
ObjectName addLoggerMBean(Logger logger) {
String name = logger.getName();
ObjectName objectName = null;
try {
LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger);
objectName = new ObjectName("log4j", "logger", name);
if (!server.isRegistered(objectName)) {
registerMBean(loggerMBean, objectName);
NotificationFilterSupport nfs = new NotificationFilterSupport();
nfs.enableType(ADD_APPENDER + logger.getName());
log.debug("---Adding logger [" + name + "] as listener.");
nbs.addNotificationListener(loggerMBean, nfs, null);
vAttributes.add(new MBeanAttributeInfo("logger=" + name, "javax.management.ObjectName",
"The " + name + " logger.", true, true, // this makes the object
// clickable
false));
}
} catch(JMException e) {
log.error("Could not add loggerMBean for ["+name+"].", e);
} catch(RuntimeException e) {
log.error("Could not add loggerMBean for ["+name+"].", e);
}
return objectName;
}
代码示例来源:origin: apache/log4j
public
ObjectName addLoggerMBean(String name) {
Logger cat = LogManager.exists(name);
if(cat != null) {
return addLoggerMBean(cat);
} else {
return null;
}
}
代码示例来源:origin: org.apache.hadoop/zookeeper
/**
* 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());
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Starts instance of HtmlAdapterServer.
* @deprecated
*/
public void start() {
MBeanServer server = MBeanServerFactory.createMBeanServer();
Object html = createServer();
try {
log.info("Registering HtmlAdaptorServer instance.");
server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
log.info("Registering HierarchyDynamicMBean instance.");
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
} catch(JMException e) {
log.error("Problem while registering MBeans instances.", e);
return;
} catch(RuntimeException e) {
log.error("Problem while registering MBeans instances.", e);
return;
}
startServer(html);
}
}
代码示例来源:origin: apache-log4j/log4j
public HierarchyDynamicMBean() {
hierarchy = LogManager.getLoggerRepository();
buildDynamicMBeanInfo();
}
代码示例来源:origin: org.apache.activemq/activemq-all
ObjectName addLoggerMBean(Logger logger) {
String name = logger.getName();
ObjectName objectName = null;
try {
LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger);
objectName = new ObjectName("log4j", "logger", name);
if (!server.isRegistered(objectName)) {
registerMBean(loggerMBean, objectName);
NotificationFilterSupport nfs = new NotificationFilterSupport();
nfs.enableType(ADD_APPENDER + logger.getName());
log.debug("---Adding logger [" + name + "] as listener.");
nbs.addNotificationListener(loggerMBean, nfs, null);
vAttributes.add(new MBeanAttributeInfo("logger=" + name, "javax.management.ObjectName",
"The " + name + " logger.", true, true, // this makes the object
// clickable
false));
}
} catch(JMException e) {
log.error("Could not add loggerMBean for ["+name+"].", e);
} catch(RuntimeException e) {
log.error("Could not add loggerMBean for ["+name+"].", e);
}
return objectName;
}
代码示例来源:origin: apache/log4j
public
void postRegister(java.lang.Boolean registrationDone) {
log.debug("postRegister is called.");
hierarchy.addHierarchyEventListener(this);
Logger root = hierarchy.getRootLogger();
addLoggerMBean(root);
}
代码示例来源:origin: NGDATA/lilyproject
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
hdm.addLoggerMBean(rootLogger.getName());
hdm.addLoggerMBean(logger.getName());
代码示例来源:origin: apache-log4j/log4j
public
void start() {
MBeanServer server = MBeanServerFactory.createMBeanServer();
HtmlAdaptorServer html = new HtmlAdaptorServer();
try {
log.info("Registering HtmlAdaptorServer instance.");
server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
log.info("Registering HierarchyDynamicMBean instance.");
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
} catch(Exception e) {
log.error("Problem while regitering MBeans instances.", e);
return;
}
html.start();
}
}
内容来源于网络,如有侵权,请联系作者删除!