WEB开发网
开发学院软件开发Java 为 Eclipse 插件添加日志框架:两种增强 Eclipse ... 阅读

为 Eclipse 插件添加日志框架:两种增强 Eclipse 日志功能的方法

 2009-12-14 00:00:00 来源:WEB开发网   
核心提示: 清单 1. TestPlugin 插件类中 PluginLogManager 的配置privatestaticfinalStringLOG_PROPERTIES_FILE="logger.properties";publicvoidstart(BundleContextcon


清单 1. TestPlugin 插件类中 PluginLogManager 的配置
private static final String LOG_PROPERTIES_FILE = "logger.properties"; 
public void start(BundleContext context) throws Exception { 
  super.start(context); 
  configure(); 
} 
private void configure() { 
  try { 
   URL url = getBundle().getEntry("/" + LOG_PROPERTIES_FILE); 
   InputStream propertiesInputStream = url.openStream(); 
   if (propertiesInputStream != null) { 
     Properties props = new Properties(); 
     props.load(propertiesInputStream); 
     propertiesInputStream.close(); 
     this.logManager = new PluginLogManager(this, props); 
     this.logManager.hookPlugin( 
     TestPlugin.getDefault().getBundle().getSymbolicName(), 
     TestPlugin.getDefault().getLog()); 
   } 
  } 
  catch (Exception e) { 
   String message = "Error while initializing log properties." + 
            e.getMessage(); 
   IStatus status = new Status(IStatus.ERROR, 
   getDefault().getBundle().getSymbolicName(), 
   IStatus.ERROR, message, e); 
   getLog().log(status); 
   throw new RuntimeException( 
      "Error while initializing log properties.",e); 
  }     
} 

上一页  1 2 3 4 5 6 7 8 9  下一页

Tags:Eclipse 插件 添加

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接