You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Shane McEneaney <sh...@hotmail.com> on 2004/09/08 10:07:38 UTC

log4j 1.2.8 and JMX - Dynamic changing of log levels

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

Re: log4j 1.2.8 and JMX - Dynamic changing of log levels

Posted by Mike Zirkle <mi...@sbcglobal.net>.
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