logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42017] New: - InstanceAlreadyExistsException using MBean
Date Mon, 02 Apr 2007 10:06:53 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42017>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42017

           Summary: InstanceAlreadyExistsException using MBean
           Product: Log4j
           Version: 1.2
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: f.dalan@mbm.it


Hi, when I use the MBean architecture with mx4j implementation to manage the 
logging parameters, I have an InstanceAlreadyExistsException. This happen when 
the org.apache.log4j.jmx.AppenderDynamicMBean try to register a layout 
(registerLayoutMBean method) because do not check if the MBean is already 
registered. Here there is the code that I use

MBeanServer server = MBeanServerFactory.createMBeanServer();
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
...
LoggerRepository r = LogManager.getLoggerRepository();
Enumeration enum = r.getCurrentLoggers();
Logger logger = null;
while (enum.hasMoreElements()) {
  logger = (Logger) enum.nextElement();
  ObjectName dummy = new ObjectName("log4j", "logger", logger.getName());
  if (!server.isRegistered(dummy))
    hdm.addLoggerMBean(logger.getName());
}

and the log4j.properties

# Console is set to be a ConsoleAppender.
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d %-5p %c{1}.%M - %m%n

# FileConsole is set to be a FileAppender.
log4j.appender.FileConsole.File=\\wcubecoils.log
log4j.appender.FileConsole=org.apache.log4j.FileAppender
log4j.appender.FileConsole.layout=org.apache.log4j.PatternLayout
log4j.appender.FileConsole.layout.ConversionPattern=%d %-5p %c{1}.%M - %m%n

# the root logger
log4j.rootLogger=INFO, FileConsole

# wcube logging configuration...
log4j.logger.it.mbm.wcube.processmessage=TRACE, FileConsole
log4j.logger.it.mbm.wcube.mq.bo.action=TRACE, FileConsole

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message