You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by DonLuigi <lu...@gmail.com> on 2011/08/24 11:32:47 UTC

How to: Log level per bundle

Hello.


Is there possibility in Karaf to set different log level for different
bundles?


As a "workarround" I tried using log4j directly instead of Logging service. 

First I configured log level for my bundle in org.ops4j.pax.logging.cfg:
log4j.logger.rts = ALL

I also turned on log4j.debug = true just to be sure that config is reloaded.

After I save config file I get following notification:

log4j: Parsing for [root] with value=[INFO, out].
log4j: Level token is [INFO].
log4j: Category root set to INFO
...
log4j: Parsing for [rts] with value=[ALL].
log4j: Level token is [DEBUG].
log4j: Category rts set to DEBUG
log4j: Handling log4j.additivity.rts=[null]
log4j: Finished configuring.

Then in my bundle I do Logger.getLogger ("rts").fine ("blah") and nothing
happens!

Using debugger shows that rts Logger has level set to INFO and not ALL.  It
seems that log4j is only considering root logger configuration.

Anybody knows what is going on?

P.S. I tried all sorts of combinations.

Cheers

--
View this message in context: http://karaf.922171.n3.nabble.com/How-to-Log-level-per-bundle-tp3280504p3280504.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: How to: Log level per bundle

Posted by Achim Nierbeck <bc...@googlemail.com>.
Well you still can set the log levels for your Packages so that should
be sufficient.
Together with the MDCSifting appender you have a bundle dependent log file.

regards, Achim

2011/8/24 DonLuigi <lu...@gmail.com>:
> Hello.
>
>
> Is there possibility in Karaf to set different log level for different
> bundles?
>
>
> As a "workarround" I tried using log4j directly instead of Logging service.
>
> First I configured log level for my bundle in org.ops4j.pax.logging.cfg:
> log4j.logger.rts = ALL
>
> I also turned on log4j.debug = true just to be sure that config is reloaded.
>
> After I save config file I get following notification:
>
> log4j: Parsing for [root] with value=[INFO, out].
> log4j: Level token is [INFO].
> log4j: Category root set to INFO
> ...
> log4j: Parsing for [rts] with value=[ALL].
> log4j: Level token is [DEBUG].
> log4j: Category rts set to DEBUG
> log4j: Handling log4j.additivity.rts=[null]
> log4j: Finished configuring.
>
> Then in my bundle I do Logger.getLogger ("rts").fine ("blah") and nothing
> happens!
>
> Using debugger shows that rts Logger has level set to INFO and not ALL.  It
> seems that log4j is only considering root logger configuration.
>
> Anybody knows what is going on?
>
> P.S. I tried all sorts of combinations.
>
> Cheers
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/How-to-Log-level-per-bundle-tp3280504p3280504.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
--
*Achim Nierbeck*


Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
blog <http://notizblog.nierbeck.de/>