[英]Eclipse PDE logging missing method
If you let Eclipse create the Activator class for you and you specified the 'This plug-in will make contributions to the UI' option then the class will look something like: 如果让Eclipse为您创建Activator类,并且指定了“此插件将为UI做出贡献”选项,则该类将类似于:
public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
public Activator() {
}
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(final BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
public static Activator getDefault() {
return plugin;
}
}
You can then call 然后你可以打电话
ILog log = Activator.getDefault().getLog();
to access the log interface 访问日志界面
From the FAQ: " The log for a plug-in is accessed from the plug-in's class, using getLog inherited from Plugin ". 在FAQ中:“ 使用从Plugin继承的getLog从插件的类访问插件的日志 ”。 This means, you need to access the log from your own plugin's class.
这意味着,您需要从您自己的插件的类访问日志。
So, essentially, you'll need to add in your AbstractHandler
following: 因此,从本质上讲,您需要在您的
AbstractHandler
添加以下内容:
ILog log = MyPluginClass.getInstance().getLog();
Remember, that getInstance()
is not a standard method, but plugins are supposed to work as singletons. 记住,
getInstance()
不是标准方法,但是插件应该作为单例工作。 So, you maybe need to add this method. 因此,您可能需要添加此方法。
The method is documented in the Eclipse Help which is a good reference documentation if you have any questions regarding Eclipse and its implementation. 如果您对Eclipse及其实现有任何疑问,请在Eclipse帮助中找到该方法,该参考是很好的参考文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.