2013-12-18 76 views
1

我配置了pax日志记录在我的osgi运行时和测试标准osgi日志服务但没有记录日志记录。无论如何,所有其他日志API似乎按照[2]的预期工作。我错过了什么吗?是否支持pax日志记录支持标准osgi日志服务api

LogService logService; 

public void start(BundleContext bundleContext) throws Exception { 

    ServiceReference ref = bundleContext.getServiceReference(LogService.class.getName()); 
    if (ref != null) 
    { 
     logService = (LogService) bundleContext.getService(ref); 
     logService.log(LogService.LOG_INFO, " ----------- Testing OSGI logging on bundle start -------------------- "); 
} 

[1] https://ops4j1.jira.com/wiki/display/paxlogging/Installation

[2] https://ops4j1.jira.com/wiki/display/paxlogging/Pax+Logging

感谢

回答

1

这是一个典型的错误使用OSGi:你期望的LogService可用在启动时。如果延迟,你最终会得到一个null引用并且不记录任何东西。

尝试在发布服务时使用注入服务的标准方法,如Declarative Services component model

一个很好的教程可以找到on the IBM Infocenter

相关问题