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 gaspode <ga...@gmail.com> on 2006/11/17 15:40:12 UTC

Access Log4J with JMX ?

Hi all,

I'd like to change the Log4J configuration remotely while my app is running.
I started a simple JMX solution when I noticed that Log4J already includes a
JMX package : org.apache.log4j.jmx.

Unfortunately, this package is not well documented, and I could not find any
mention of it in "The Complete Log4J Manual" (Ceki Gülcü) that I recently
bought.

Could somebody explain me how to use it or point me to some online doc?

I understand that LoggerDynamicMBean, LayoutDynamicMBean and
LoggerDynamicMBean are all wrapper around a Logger, a Layout or an Appender.
But most of my apps use lots of Loggers, Appenders,... do I have to publish
a MBean for each of them? Isn't that a bit awkward? If I access them with
jconsole I will end up with lot's of hard to read info. Or is there a Log4J
JMX GUI client somewhere that present me all that in a friendly way? Or do I
have to create one? (and if so, is anybody interrested in joining the
project ? :-> ).

Cheers all,

me.

Re: Access Log4J with JMX ?

Posted by Curt Arnold <ca...@apache.org>.
I don't think any of the active log4j committers have much insight  
into the existing JMX code, but if I'm wrong hopefully they will  
speak up.  Search for bug reports for log4j with JMX in the summary  
at at http://issues.apache.org/bugzilla/query.cgi and you will come  
up with a list of several reported bugs.  You can also search the  
log4j-dev mailing list for JMX at http://marc.theaimsgroup.com/? 
l=log4j-dev&w=2&r=1&s=JMX&q=b.

My understanding is that the JMX code that is in the log4j code base  
was dropped in pretty much as it is with no earlier discussion and no  
further development.  I recall that one of the comments described the  
JMX support as not ready for production use.  If you are interested  
in working on this area, I would welcome your efforts.  I'd suggest  
the following steps:

1. Review the CLA at http://www.apache.org/licenses.  If you were to  
submit a replacement or alternative JMX implementation for log4j, it  
would likely warrant you executing one of those.

2. Review the bugzilla and mailing list discussions on JMX in log4j  
and post a summary to log4j-dev.

3. Start a discussion on log4j-dev with either open questions, a list  
of requirements or a proposal and see what everyone thinks.


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


Re: Access Log4J with JMX ?

Posted by Nicolas DE LOOF <ni...@capgemini.com>.
You have ot configure a JMX remote connector. See mx4j doc about JSR160 
and Spring JMX doc for infos on this.
You can the use Java5 jconsole to acces remote MBeans and invoke 
methods, like "createLogger" that allow to get a log4j logger and the 
change it's "level" attribute.

Nico.

ying lcs a écrit :
> Thanks. If I use the mbean exporter, how can I change the parameter 
> remotely?
> What jmx client that I can use to change the JMX-parameter after i did 
> this?
>
>
>
> On 11/17/06, Nicolas DE LOOF <ni...@capgemini.com> wrote:
>>
>> I'm using it via Spring jmx this way :
>>
>>     <bean id="mbeanExporter"
>>         class="org.springframework.jmx.export.MBeanExporter">
>>         <property name="beans">
>>             <map>
>>                 <entry key="log4j:hiearchy=default">
>>                     <bean
>> class="org.apache.log4j.jmx.HierarchyDynamicMBean"/>
>>                 </entry>
>>             </map>
>>         </property>
>>         <property name="server" ref="mbeanServer"/>
>>     </bean>
>>
>> This gives me acces to the log4j MBeans to get existing loggers and
>> change levels. Please note I can ONLY get MBeans for existing loggers,
>> so I have to define categories in log4j.xml for every logger in my app
>> that I'd like to configure at runtime.
>>
>> Maybe next log4j versions will allow a finer JMX management.
>>
>> Nico.
>>
>> gaspode a écrit :
>> > Hi all,
>> >
>> > I'd like to change the Log4J configuration remotely while my app is
>> > running.
>> > I started a simple JMX solution when I noticed that Log4J already
>> > includes a
>> > JMX package : org.apache.log4j.jmx.
>> >
>> > Unfortunately, this package is not well documented, and I could not
>> > find any
>> > mention of it in "The Complete Log4J Manual" (Ceki Gülcü) that I 
>> recently
>> > bought.
>> >
>> > Could somebody explain me how to use it or point me to some online 
>> doc?
>> >
>> > I understand that LoggerDynamicMBean, LayoutDynamicMBean and
>> > LoggerDynamicMBean are all wrapper around a Logger, a Layout or an
>> > Appender.
>> > But most of my apps use lots of Loggers, Appenders,... do I have to
>> > publish
>> > a MBean for each of them? Isn't that a bit awkward? If I access 
>> them with
>> > jconsole I will end up with lot's of hard to read info. Or is there a
>> > Log4J
>> > JMX GUI client somewhere that present me all that in a friendly way?
>> > Or do I
>> > have to create one? (and if so, is anybody interrested in joining the
>> > project ? :-> ).
>> >
>> > Cheers all,
>> >
>> > me.
>> >
>>
>> This message contains information that may be privileged or 
>> confidential and is the property of the Capgemini Group. It is 
>> intended only for the person to whom it is addressed. If you are not 
>> the intended recipient,  you are not authorized to read, print, 
>> retain, copy, disseminate,  distribute, or use this message or any 
>> part thereof. If you receive this  message in error, please notify 
>> the sender immediately and delete all  copies of this message.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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


Re: Access Log4J with JMX ?

Posted by ying lcs <yi...@gmail.com>.
Thanks. If I use the mbean exporter, how can I change the parameter remotely?
What jmx client that I can use to change the JMX-parameter after i did this?



On 11/17/06, Nicolas DE LOOF <ni...@capgemini.com> wrote:
>
> I'm using it via Spring jmx this way :
>
>     <bean id="mbeanExporter"
>         class="org.springframework.jmx.export.MBeanExporter">
>         <property name="beans">
>             <map>
>                 <entry key="log4j:hiearchy=default">
>                     <bean
> class="org.apache.log4j.jmx.HierarchyDynamicMBean"/>
>                 </entry>
>             </map>
>         </property>
>         <property name="server" ref="mbeanServer"/>
>     </bean>
>
> This gives me acces to the log4j MBeans to get existing loggers and
> change levels. Please note I can ONLY get MBeans for existing loggers,
> so I have to define categories in log4j.xml for every logger in my app
> that I'd like to configure at runtime.
>
> Maybe next log4j versions will allow a finer JMX management.
>
> Nico.
>
> gaspode a écrit :
> > Hi all,
> >
> > I'd like to change the Log4J configuration remotely while my app is
> > running.
> > I started a simple JMX solution when I noticed that Log4J already
> > includes a
> > JMX package : org.apache.log4j.jmx.
> >
> > Unfortunately, this package is not well documented, and I could not
> > find any
> > mention of it in "The Complete Log4J Manual" (Ceki Gülcü) that I recently
> > bought.
> >
> > Could somebody explain me how to use it or point me to some online doc?
> >
> > I understand that LoggerDynamicMBean, LayoutDynamicMBean and
> > LoggerDynamicMBean are all wrapper around a Logger, a Layout or an
> > Appender.
> > But most of my apps use lots of Loggers, Appenders,... do I have to
> > publish
> > a MBean for each of them? Isn't that a bit awkward? If I access them with
> > jconsole I will end up with lot's of hard to read info. Or is there a
> > Log4J
> > JMX GUI client somewhere that present me all that in a friendly way?
> > Or do I
> > have to create one? (and if so, is anybody interrested in joining the
> > project ? :-> ).
> >
> > Cheers all,
> >
> > me.
> >
>
> This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

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


Re: Access Log4J with JMX ?

Posted by Nicolas DE LOOF <ni...@capgemini.com>.
I'm using it via Spring jmx this way :

    <bean id="mbeanExporter"
        class="org.springframework.jmx.export.MBeanExporter">
        <property name="beans">
            <map>
                <entry key="log4j:hiearchy=default">
                    <bean 
class="org.apache.log4j.jmx.HierarchyDynamicMBean"/>
                </entry>
            </map>
        </property>
        <property name="server" ref="mbeanServer"/>
    </bean>

This gives me acces to the log4j MBeans to get existing loggers and 
change levels. Please note I can ONLY get MBeans for existing loggers, 
so I have to define categories in log4j.xml for every logger in my app 
that I'd like to configure at runtime.

Maybe next log4j versions will allow a finer JMX management.

Nico.

gaspode a écrit :
> Hi all,
>
> I'd like to change the Log4J configuration remotely while my app is 
> running.
> I started a simple JMX solution when I noticed that Log4J already 
> includes a
> JMX package : org.apache.log4j.jmx.
>
> Unfortunately, this package is not well documented, and I could not 
> find any
> mention of it in "The Complete Log4J Manual" (Ceki Gülcü) that I recently
> bought.
>
> Could somebody explain me how to use it or point me to some online doc?
>
> I understand that LoggerDynamicMBean, LayoutDynamicMBean and
> LoggerDynamicMBean are all wrapper around a Logger, a Layout or an 
> Appender.
> But most of my apps use lots of Loggers, Appenders,... do I have to 
> publish
> a MBean for each of them? Isn't that a bit awkward? If I access them with
> jconsole I will end up with lot's of hard to read info. Or is there a 
> Log4J
> JMX GUI client somewhere that present me all that in a friendly way? 
> Or do I
> have to create one? (and if so, is anybody interrested in joining the
> project ? :-> ).
>
> Cheers all,
>
> me.
>

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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