
Hi, I want to use slf4j in Eclipse RCP Projects. My idea is to replace Activator.getDefault().getLog().log( new Status( IStatus.INFO, Activator.PLUGIN_ID, msg ) ); into class My { static Logger logger = LoggerFactory.getLogger(My.class); something() { logger.info(msg); } } But there is a problem, I need the Bundle to use the eclipse logging. It is possible to get the Bundle from the class objects. But the ILoggerFactory interface has only a getLogger( String ) method :-( And the LoggerFactory.getLogger( Class ) methods calls getLogger( c.getName ). I think it should be possible to log the Bundle in osgi containers. Is there any solution ? My idea, create an interface ILoggerFactory2 extends ILoggerFactory { Logger getLogger( Class c ); } Regrads, André -- _____________________________________________________ André Kullmann Otto Group · GroupTechnologyPartner - Dresden (GTP) Anwendungsentwickler · Touchpoints und Kunde · FI-IM-TK _______________________________________________ GroupTechnologyPartner - Dresden · Freiberger Straße 35 · 01067 Dresden Telefon +49 (0) 351 497 23 185 · Fax +49 (0) 351 497 23 119 andre.kullmann@osp-dd.de · www.ottogroup.com _______________________________________________ AG Dresden, HRB 2475 Geschäftsführer: Dr. Thomas Tribius, Martin Mildner

Am 09.04.2010 13:25, schrieb André Kullmann:
I think it should be possible to log the Bundle in osgi containers. Is there any solution ?
I've written a native SLF4J logger which routes log messages to the Equinox Extended Log Service. It should be possible to use this as a base for creating one that logs to the Eclipse log file. See http://bit.ly/cXj5Uh line 209/210. This could be done at logger creation time as well. Currently it does this on every call but this is likely too much (and unnecessary) overhead. BTW, I also created an Equinox Framework hook which hooks into the Framework look to bring all the legacy Eclipse logging into SLF4J. See http://bit.ly/bzVOJC. Greetings from Jena, Gunnar -- Gunnar Wagenknecht gunnar@wagenknecht.org http://wagenknecht.org/

Hi Gunnar, thanks for the repley. It's an nice idea to use SecurityManager#getClassContext to get the bundle. I'll try it for my use case. Greetings from Dresden, André Gunnar Wagenknecht schrieb:
Am 09.04.2010 13:25, schrieb André Kullmann:
I think it should be possible to log the Bundle in osgi containers. Is there any solution ?
I've written a native SLF4J logger which routes log messages to the Equinox Extended Log Service. It should be possible to use this as a base for creating one that logs to the Eclipse log file.
See http://bit.ly/cXj5Uh line 209/210. This could be done at logger creation time as well. Currently it does this on every call but this is likely too much (and unnecessary) overhead.
BTW, I also created an Equinox Framework hook which hooks into the Framework look to bring all the legacy Eclipse logging into SLF4J. See http://bit.ly/bzVOJC.
Greetings from Jena, Gunnar
participants (3)
-
Andre Kullmann
-
André Kullmann
-
Gunnar Wagenknecht