Class Logger

java.lang.Object
org.apache.felix.dm.Logger
All Implemented Interfaces:
EventListener, org.osgi.framework.ServiceListener

public class Logger extends Object implements org.osgi.framework.ServiceListener
This class mimics the standard OSGi LogService interface. An instance of this class is used by the dependency manager for all logging. By default this class logs messages to standard out. The log level can be set to control the amount of logging performed, where a higher number results in more logging. A log level of zero turns off logging completely. The log levels match those specified in the OSGi Log Service. This class also tracks log services and will use the highest ranking log service, if present, as a back end instead of printing to standard out. The class uses reflection to invoking the log service's method to avoid a dependency on the log interface, which is also why it does not actually implement LogService. This class is in many ways similar to the one used in the system bundle for that same purpose.
Author:
Felix Project Team
  • Field Details

  • Constructor Details

    • Logger

      public Logger(org.osgi.framework.BundleContext context)
  • Method Details

    • log

      public final void log(int level, String msg)
    • log

      public final void log(int level, String msg, Throwable throwable)
    • log

      public final void log(org.osgi.framework.ServiceReference sr, int level, String msg)
    • log

      public final void log(org.osgi.framework.ServiceReference sr, int level, String msg, Throwable throwable)
    • doLog

      protected void doLog(org.osgi.framework.ServiceReference sr, int level, String msg, Throwable throwable)
    • serviceChanged

      public final void serviceChanged(org.osgi.framework.ServiceEvent event)
      This method implements the callback for the ServiceListener interface. It is public as a byproduct of implementing the interface and should not be called directly. This method tracks run-time changes to log service availability. If the log service being used by the framework's logging mechanism goes away, then this will try to find an alternative. If a higher ranking log service is registered, then this will switch to the higher ranking log service.
      Specified by:
      serviceChanged in interface org.osgi.framework.ServiceListener
    • setEnabledLevel

      public void setEnabledLevel(int enabledLevel)
    • setDebugKey

      public void setDebugKey(String debugKey)
    • getDebugKey

      public String getDebugKey()
    • err

      public void err(String format, Object... params)
    • err

      public void err(String format, Throwable err, Object... params)
    • warn

      public void warn(String format, Object... params)
    • warn

      public void warn(String format, Throwable err, Object... params)
    • info

      public boolean info()
    • info

      public void info(String format, Object... params)
    • info

      public void info(String format, Throwable err, Object... params)
    • debug

      public boolean debug()
    • debug

      public void debug(String format, Object... params)
    • debug

      public void debug(String format, Throwable err, Object... params)