在其他服务之前激活OSGI LogListener? [英] Activating an OSGI LogListener before other services?

查看:67
本文介绍了在其他服务之前激活OSGI LogListener?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Felix,Declarative Services和Maven编写基于OSGI的桌面应用程序.它将使用JavaFX,所以我也使用 Drombler FX .

I am writing a OSGI-based desktop application, using Apache Felix, Declarative Services and Maven. It's going to use JavaFX, so I'm using Drombler FX too.

在我开发的捆绑软件中,我想使用适当的日志记录机制,并且我目前正在尝试制作

In the bundles I develop, I'd like to use an appropriate logging mechanism, and I'm currently trying to make Apache Felix Log work. I have no problem getting a LogService but this is not sufficient to make output appear on the console.

网上的字眼是Everit的 osgi-loglistener-slf4j 将完成此任务,并且–足够肯定–在已激活,日志输出将显示在控制台上.

The word on the net is that Everit's osgi-loglistener-slf4j will do the job and – sure enough – after osgi-loglistener-slf4j has been activated log output appears on the console.

但是,直到之后我所有的捆绑包都不会激活osgi-loglistener-slf4j,因此我感兴趣的日志信息都不会输出.我尝试在我的第一个捆绑软件中为LogLevel创建一个@Reference,以尝试强制激活osgi-loglistener-slf4j,但是没有成功.

However, osgi-loglistener-slf4j is not activated until after all my own bundles, so none of the log information that I am interested in is output. I've tried creating a @Reference to a LogLevel in my first bundle to try and force activation of osgi-loglistener-slf4j, but without success.

如何先激活osgi-loglistener-slf4j?我已经阅读了有关开始级别的信息,但是我找不到有关如何在我的上下文中应用它们的任何信息(即台式机而不是服务器,因此没有PAX或Karaf; Maven;并且我使用NetBeans,因此没有Eclipse).

How do I get osgi-loglistener-slf4j activated before everything else? I have read about start levels, but I haven't been able to find any information about how to apply them in my context (i.e. desktop not server, so no PAX or Karaf; Maven; and I use NetBeans, so no Eclipse).

推荐答案

Drombler FX使用SLF4J:

Drombler FX uses SLF4J: http://www.drombler.org/drombler-fx/0.7/docs/tutorial/logging.html#logging

只需使用以下内容,它便会起作用:

Just use the following and it should work:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;  

...

private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);

在POM中添加以下依赖项:

In the POM add the following dependency:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>

这篇关于在其他服务之前激活OSGI LogListener?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆