We've done that in Apache Karaf by leveraging
SecurityManager#getClassContext and grabbing the bundle informations
from the classes classloader.

On Wed, Nov 3, 2010 at 15:37, Igmar Palsenberg <[email protected]> wrote:
>
> Hi Jeff,
>
>> - in Y walk down the stack the number of frames you are from the real logger 
>> (e.g., X calls Y directly, look down one or two frames).
>> - Get the classloader for the method running in that frame.
>> - If you are on a recent framework then that classloader may well be a 
>> org.osgi.framework.BundleReference. If it is, cast and call getBundle().
>> - carry on
>>
>> For some sample stack walking code, look at Equinox's 
>> ContextFinder.basicFindClassLoaders() method [0].
>
> A problem with that is that the stacktrace doesn't give me bundle 
> information. If you have 2 bundles with the same class Foo(), you don't know 
> which bundle that Foo in the stacktrace refers to. You only get a name / 
> method, not a reference, else you could have find out what classloader loaded 
> that class, and so find out the bundle.
>
> It's a nasty problem, but solution is more then welcome :  All generic code 
> logging in one file isn't usefull without info what bundle used the generic 
> code.
>
>
>
>        Igmar
>
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to