Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:04:46+00:00 2026-06-10T02:04:46+00:00

I’m developing a OSGi Equinox bundle and I’d like to add some logging to

  • 0

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.

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:

OSGi Log Service

So I came up with an Activator that looks like this:

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;
}

Well, I never see the logged message in the OSGi console…looking for some more info, I found this thread:

How to use Equiniox’s LogService ?

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…)

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…

Thanks!
Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:04:48+00:00Added an answer on June 10, 2026 at 2:04 am

    To answer the question directly:

    A LogService is a service responsible for storing log messages.
    A LogReaderService is a service responsible for reading these log messages and dispatching them to log listeners.
    The binding between these is done automatically.
    What you will do yourself is log messages to the LogService on the one side, and possibly bind LogListeners to the LogReaderService, that will write out the logs somewhere, for example the console, on the other side.

    To solve your problem of the logs not appearing, you need to do a few additional things.

    First of all, did you install a bundle offering an implementation of the LogService and the LogReaderService into your osgi container?

    You can check for the presense of an org.osgi.service.log.LogService by adding something like this to your Activator:

    if(logService != null){ 
            System.out.println("There is a LogService available"); 
            logService.log(LogService.LOG_INFO, "Yee ha, I'm logging!"); 
    } 
    else { 
            System.out.println("There is no LogService available"); 
    }
    

    Or just type “bundles” in the equinox console and look for a bundle offering an org.osgi.service.log.LogService and an org.osgi.service.log.LogReaderService.

    If no LogService is available, install one. For example:

    install http://oscar-osgi.sf.net/repo/log/log.jar
    

    The org.apache.log4j equinox dependency offers such a service too.

    Start and stop your own bundle again. It should now print “There is a LogService available”.

    Now your messages are logged to the LogService and processed by the LogReaderService, but still, since there might be no LogListeners registered with this service(depending on other bundles started),

    You might need to have to add a LogListener yourself in your bundle Activator.

    For an example bundle Activator who does this, check http://blog.kornr.net/index.php/2008/12/09/understanding-the-osgi-logging-service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.