类 Logger

  • 所有已实现的接口:
    java.util.EventListener, ServiceListener

    public class Logger
    extends java.lang.Object
    implements ServiceListener

    This class mimics the standard OSGi LogService interface. An instance of this class is used by the framework 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 (i.e., 1 = error, 2 = warning, 3 = information, and 4 = debug). The default value is 1.

    This class also uses the System Bundle's context to track 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.

    • 构造器概要

      构造器 
      构造器 说明
      Logger()  
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      protected void doLog​(Bundle bundle, ServiceReference sr, int level, java.lang.String msg, java.lang.Throwable throwable)  
      int getLogLevel()  
      void log​(int level, java.lang.String msg)  
      void log​(int level, java.lang.String msg, java.lang.Throwable throwable)  
      void log​(Bundle bundle, int level, java.lang.String msg)  
      void log​(Bundle bundle, int level, java.lang.String msg, java.lang.Throwable throwable)  
      void log​(ServiceReference sr, int level, java.lang.String msg)  
      void log​(ServiceReference sr, int level, java.lang.String msg, java.lang.Throwable throwable)  
      void serviceChanged​(ServiceEvent event)
      This method implements the callback for the ServiceListener interface.
      void setLogLevel​(int i)  
      protected void setSystemBundleContext​(BundleContext context)  
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • Logger

        public Logger()
    • 方法详细资料

      • setLogLevel

        public final void setLogLevel​(int i)
      • getLogLevel

        public final int getLogLevel()
      • setSystemBundleContext

        protected void setSystemBundleContext​(BundleContext context)
      • log

        public final void log​(int level,
                              java.lang.String msg)
      • log

        public final void log​(int level,
                              java.lang.String msg,
                              java.lang.Throwable throwable)
      • log

        public final void log​(ServiceReference sr,
                              int level,
                              java.lang.String msg)
      • log

        public final void log​(ServiceReference sr,
                              int level,
                              java.lang.String msg,
                              java.lang.Throwable throwable)
      • log

        public final void log​(Bundle bundle,
                              int level,
                              java.lang.String msg)
      • log

        public final void log​(Bundle bundle,
                              int level,
                              java.lang.String msg,
                              java.lang.Throwable throwable)
      • doLog

        protected void doLog​(Bundle bundle,
                             ServiceReference sr,
                             int level,
                             java.lang.String msg,
                             java.lang.Throwable throwable)
      • serviceChanged

        public final void serviceChanged​(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.
        指定者:
        serviceChanged 在接口中 ServiceListener
        参数:
        event - The ServiceEvent object.