1

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

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

先谢谢各位了。

4

1 回答 1

1

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

于 2018-01-03T20:29:48.417 回答