You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by xav <xa...@eaton.com> on 2014/07/11 11:41:14 UTC

Karaf 2.3.5 Set the log Level programmatically

Hi all,

I try to set the log level in my bundle.
For example, I want to set programmatically the level (DEBUG, INFO, etc.)
for a specific package (a.b.c.d)
I saw logMBean, but I can not use it??? I try with a service, but I don't
know which one?
I am wrong??? any help will be appreciate.

Thanks a lot

Regards



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-2-3-5-Set-the-log-Level-programmatically-tp4034161.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 2.3.5 Set the log Level programmatically

Posted by xav <xa...@eaton.com>.
Hi JB,

I want to bring a precision:
In my bundle, I want doing programmatically, than the same things when I
modify the org.ops4j.pax.logging.cfg file, i.e.

log4j.logger.a.b.c=DEBUG, toto
log4j.appender.toto=org.apache.log4j.RollingFileAppender
....
....

after some code 
 
log4j.logger.a.b.c=INFO, toto
log4j.appender.toto=org.apache.log4j.RollingFileAppender
....
....

Regards



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-2-3-5-Set-the-log-Level-programmatically-tp4034161p4034164.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 2.3.5 Set the log Level programmatically

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Xav,

no problem, we are dedicated for you guys ;)

Regards
JB

On 07/15/2014 12:15 PM, xav wrote:
> Hi JB,
>
> Thanks, I used LogService, it's works.
>
> Thanks for your help.
>
> Regards
>
> Xav
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-2-3-5-Set-the-log-Level-programmatically-tp4034161p4034222.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 2.3.5 Set the log Level programmatically

Posted by xav <xa...@eaton.com>.
Hi JB,

Thanks, I used LogService, it's works.

Thanks for your help.

Regards

Xav



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-2-3-5-Set-the-log-Level-programmatically-tp4034161p4034222.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 2.3.5 Set the log Level programmatically

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Xav,

no, the service is org.apache.karaf.log.core.LogService. So, you have to do:

ServiceReference<LogService> ref = (ServiceReference<LogService>) 
bc.getServiceReference(LogService.class.getName());

The LogService interface is provided by org.apache.karaf.log.core bundle.

For the LogMBean, you have to access using the MBeanServer. The 
ObjectName is org.apache.karaf:type=log,name=*.

Regards
JB

On 07/11/2014 03:53 PM, xav wrote:
> ok, but with LogMBean, is it a service ?? this name is? I try with:
>
> ServiceReference<LogMBean> sref = (ServiceReference<LogMBean>)
> bc.getServiceReference(LogMBean.class.getName());
>
> But not found, the sref is null and to LogMBean logMBean, how can use it?
>
> Regards
>
> Xav
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-2-3-5-Set-the-log-Level-programmatically-tp4034161p4034170.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 2.3.5 Set the log Level programmatically

Posted by xav <xa...@eaton.com>.
ok, but with LogMBean, is it a service ?? this name is? I try with:

ServiceReference<LogMBean> sref = (ServiceReference<LogMBean>)
bc.getServiceReference(LogMBean.class.getName());

But not found, the sref is null and to LogMBean logMBean, how can use it?

Regards

Xav




--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-2-3-5-Set-the-log-Level-programmatically-tp4034161p4034170.html
Sent from the Karaf - User mailing list archive at Nabble.com.