title: How do LogService and LogReaderService in Equinox work along?
body: <p>I'm developing a OSGi Equinox bundle and I'd like to add some logging to it, mostly to be redirected to the OSGi console, just for debugging purposes.</p>
  
  <p>After discarding the usage of log4j, since there are a couple of logging services in Equinox (LogService and ExtendedLogService), I found this article describing how to use the LogService:</p>
  
  <p><a href="http://www.eclipsezone.com/eclipse/forums/t85084.html" rel="nofollow noreferrer">OSGi Log Service</a></p>
  
  <p>So I came up with an Activator that looks like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>package org.example.servlet;
  
  import org.osgi.framework.BundleActivator;
  import org.osgi.framework.BundleContext;
  import org.osgi.framework.ServiceReference;
  import org.osgi.service.log.LogService;
  import org.osgi.util.tracker.ServiceTracker;
  import org.eclipse.equinox.log.ExtendedLogService;
  
  public class Activator implements BundleActivator {
  
  private static BundleContext context;
  private ServiceTracker logServiceTracker;
  private LogService logService;
  
  static BundleContext getContext() {
      return context;
  }
  
  /*
   * (non-Javadoc)
   * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
   */
  public void start(BundleContext bundleContext) throws Exception {
      Activator.context = bundleContext;      
      // create a tracker and track the log service
      logServiceTracker = new ServiceTracker(context, LogService.class.getName(), null);
      logServiceTracker.open();
  
      // grab the service
      logService = (LogService) logServiceTracker.getService();
  
      if(logService != null)
          logService.log(LogService.LOG_INFO, "Yee ha, I'm logging!");
  }
  
  /*
   * (non-Javadoc)
   * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
   */
  public void stop(BundleContext bundleContext) throws Exception {
      Activator.context = null;
  }
  </code></pre>
  
  <p>Well, I never see the logged message in the OSGi console...looking for some more info, I found this thread:</p>
  
  <p><a href="http://www.eclipsezone.com/eclipse/forums/t85084.html" rel="nofollow noreferrer">How to use Equiniox's LogService ?</a></p>
  
  <p>Some answers suggest that I should implement a LogServiceReader object that actually listens for logging events and (this is just my guess), redirects logged messages to whatever (file, console, etc...)</p>
  
  <p>Now my question, more than how to implement this interface, is how do I do the binding between my implementation of the LogServiceReader and the LogService used in the Activator...</p>
  
  <p>Thanks!
  Alex</p>