Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Logging in OSGI bundles

Avatar

Former Community Member

Lets say I have an OSGI bundle and it implements an Activator, and in that Activator class it wants to log out some information. For example

import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class Activator implements BundleActivator { private static final Logger logger = LoggerFactory.getLogger(Activator.class);     @Override public void start(BundleContext context) throws Exception { logger.info("Entered start method"); } @Override public void stop(BundleContext context) throws Exception { logger.info("Entered stop method"); } ...

Where abouts should those log messages appear ?

I had assumed that they would be in /logs/error.log but they don't turn up ?

It may be that I need to use a different Logger (i.e. JCL or Log4j), but if I do I'm not sure how to configure them (and maybe I should use log4j-over-slf4j or jcl-over-slf4j bridge API's) ??

Maybe I need to include an slf4j-log4j or slf4j-simple binding JAR (although I have experienced problems when doing that in the recent past - specifically it seems to stop nearly all output to errors.log) ??

I couldn't find the place where the global logging config is stored ?

I may at some point want to create my own log configuration for each application ?

Can anyone point me to some clues (I have read a number of articles but couldn't find the detail needed to crack this one) ?

many thanks

Fraser.

1 Accepted Solution

Avatar

Correct answer by
Level 10
2 Replies

Avatar

Correct answer by
Level 10

Avatar

Former Community Member

An update. After creating a new application and deploying the service and taglib bundles, the log events for start/stop DID appear in the global error.log file (so it was probably not happening before because of the OSGi caching policy or something similar).