【问题标题】:Kura OSGi - Console does not view my textKura OSGi - 控制台不查看我的文本
【发布时间】:2018-01-03 17:38:36
【问题描述】:

我正在尝试将输出输入我的控制台,但它不起作用。我有以下示例代码:

package org.eclipse.kura.example.hello_osgi;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HelloOsgi {

private static final Logger s_logger = LoggerFactory.getLogger(HelloOsgi.class);

private static final String APP_ID = "org.eclipse.kura.example.hello_osgi";

protected void activate(ComponentContext componentContext) {
    s_logger.info("Bundle " + APP_ID + " has started!");

    //console should view this
    s_logger.debug(APP_ID + ": This is a debug message."); 
}

protected void deactivate(ComponentContext componentContext) {
    s_logger.info("Bundle " + APP_ID + " has stopped!");
    }
}

控制台输出:

...
ss
"Framework is launched."

osgi> install file:/Users/myname/eclipseworkspace/org.eclipse.kura.example.hello_osgi
undle id is 1023
osgi> start 1023
1023 ACTIVE org.eclipse.kura.example.hello_osgi_1.0.0.qualifier
osgi> ((HERE SHOULD BE MY TEXT))

另外,让我告诉你,处理 Kura 和 OSGi 对我来说仍然是新事物。但我认为仅这个问题就足以说明这一点。 :D

提前谢谢各位。

【问题讨论】:

    标签: eclipse console osgi bundle kura


    【解决方案1】:

    日志输出不会发送到 OSGi 控制台,而是发送到 Kura 日志文件。您应该在 /var/log/kura.log 中看到您的输出。

    【讨论】:

    • 第一:感谢您的快速回答。那么 OSGi 控制台会发生什么?我想实现如上所述的输出。 (例如“osgi>((这里应该是我的文本))”)
    • @meric 你试过System.out吗?
    • 是的,我试过了,“System.out”不是我想要的。谢谢。我打开了错误的控制台 ^^ 需要 Equinox 控制台。
    猜你喜欢
    • 1970-01-01
    • 2021-07-30
    • 2014-02-11
    • 2013-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多