我已将 slf4j 1.6.1、logback-core-0.9.24.jar 和 logback-classic-0.9.24.jar 添加到我的目标平台,并将它们作为依赖项添加到插件项目的 MANIFEST 文件中。
在激活器中我这样做:
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Activator implements BundleActivator {
private static final Logger logger = LoggerFactory.getLogger(Activator.class
.getName());
private static Activator defaultInstance;
public Activator() {
Activator.defaultInstance = this;
}
/*
* (non-Javadoc)
*
* @see
* org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext )
*/
public void start(BundleContext context) throws Exception {
System.out.println(logger.isInfoEnabled());
System.out.println(logger.isDebugEnabled());
System.out.println(logger.isWarnEnabled());
System.out.println(logger.isErrorEnabled());
logger.info("llllladasdad");
}
}
}
但它只是在所有情况下都打印错误,而对于 info 调用则没有任何内容。如何在 Eclipse PDE 项目中启用 logback?