Previous Topic

Next Topic

Book Contents

Book Index

Log Filter Service

The Log Bundle provides the Log Filter Service for filtering available log entries.

Overview

The Log Filter Service, available under the com.prosyst.mbs.services.log.LogFilter interface name, provides methods for getting log entries by using a filter.

There are two methods for filtered retrieval of log entries:

Registering Bundle

The service is registered by OSGi Log Bundle.

Using the Log Filter Service

The example below shows the usage of getLogsByTime method for filtered retrieval of log entries.

Listing 1. Using the Log Filter Service.

import com.prosyst.mbs.services.log.*;  

                             . . .
  private LogFilter logFilter;

                             . . .
  public void filter(){

    // Gets the current time in milliseconds
    long time = System.currentTimeMillis();
    Enumeration enum;
    LogEntry logEntry;

    // Puts filtered logs in an enumeration
    enum = logFilter.getLogsByTime(0,time);  
    
    while(enum.hasMoreElements()) {
      logEntry = (LogEntry)enum.nextElement();

      // Prints log entries
      System.out.println("Log Filter Entry: " + logEntry.getMessage());
    }
  }