logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Zirkle <mikezir...@sbcglobal.net>
Subject Re: log4j 1.2.8 and JMX - Dynamic changing of log levels
Date Wed, 08 Mar 2006 13:30:58 GMT
Shane McEneaney <shane_mceneaney <at> hotmail.com> writes:

> 
> Hi all,
> 
> I've recently upgraded to log4j 1.2.8 to avail of the support for JMX. I
> have been unable to find documentation on how to enable JMX for log4j.
> Should this happen by default? I have successfully installed a JMX broswer
> and can see all other MBeans but none for log4j.
> 
> I want the ability to change log levels at runtime. It is not possible for
> me to change the log4j.properties as my application is included in an ear. I
> can create my own MBean and change the log level in it but I'd prefer to use
> those provided by log4j. We are using log4j through the 
> 
> Have any of you done this?
> 
> Any help greatly appreciated.
> 
> Thanks,
> 
> Shane
> 

Shane,

The MBeans must be registered in your implementation somewhere and run the
application with the following vm options "-Dcom.sun.management.jmxremote" 
Example of registering one of the jog4j MBean's:

MBeanServer server =  ManagementFactory.getPlatformMBeanServer();
ObjectName objname = new ObjectName("review javadoc");
server.registerMBean(new LoggerDynamicMBean(Logger.getRootLogger()), objname);


Then connect via RMI connector and have fun with your bean. It works rather
nicely :)


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


Mime
View raw message