@SuppressWarnings("rawtypes")
@Test
public void testTrimming() throws Exception {
File idxDir = getIdxDir();
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
try {
mbeanServer.registerMBean(hdm, new ObjectName("HouseGlass:name=log4j"));
// Add the root logger to the Hierarchy MBean
hdm.addLoggerMBean(Logger.getRootLogger().getName());
// Get each logger from the Log4J Repository and add it to
// the Hierarchy MBean created above.
LoggerRepository r = LogManager.getLoggerRepository();
java.util.Enumeration loggers = r.getCurrentLoggers();
int count = 1;
while (loggers.hasMoreElements()) {
String name = ((Logger) loggers.nextElement()).getName();
if (log.isDebugEnabled()) {
log.debug("[contextInitialized]: Registering " + name);
}
hdm.addLoggerMBean(name);
count++;
}
if (log.isInfoEnabled()) {
log.info("[contextInitialized]: " + count + " log4j MBeans registered.");
}