2017-08-07 19 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日誌記錄界面。