2017-08-07 20 views
0

当我尝试在e4应用程序中使用默认的Eclipse日志记录时,我得到一个NPE。NullPointerException当我想使用默认的e4 eclispe日志记录

import org.eclipse.e4.core.services.log.Logger; 

public abstract class AbstractdUIPlugin extends AbstractUIPlugin { 

@Inject 
Logger logger; 

public void start(BundleContext context) throws Exception { 
    super.start(context); 
    // logger = LoggingPlugin.getLogger(this); 
    logger.info("Plugin[" + getPluginId() + "] started"); 
} 
... 

回答

0

插件激活器不会被注入,因此您不能在其中使用@Inject

请注意,AbstractUIPlugin是3.x兼容模式类,而不是纯e4。

通过调用getLog()方法,可以在AbstractUIPlugin激活器中获得3.x ILog日志记录界面。