在其他服务之前激活OSGI LogListener?

编程入门 行业动态 更新时间:2024-10-27 04:32:56
本文介绍了在其他服务之前激活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.

在我开发的捆绑软件中,我想使用适当的日志记录机制,并且我目前正在尝试制作 Apache Felix Log 的工作.我得到LogService没问题,但这不足以使输出出现在控制台上.

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: www.drombler/drombler-fx/0.7/docs/tutorial/logging.html#logging

Drombler FX uses SLF4J: www.drombler/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?

本文发布于:2023-11-16 21:48:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607599.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:OSGI   LogListener

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!