图片比较多的网站怎么做,中国交通建设集团有限公司,个人能接广告联盟吗,注册公司需要什么流程做插件开发的都知道当应用跑不起来了就去看看workspace里的.log文件#xff0c;错误信息很详细,那样解决问题就方便多了#xff0c;这个功能很好#xff0c;所以学习了下#xff0c;和大家分享下#xff0c;实现的原理也就一行代码Java代码 Platform.getLog(Platform.getB…做插件开发的都知道当应用跑不起来了就去看看workspace里的.log文件错误信息很详细,那样解决问题就方便多了这个功能很好所以学习了下和大家分享下实现的原理也就一行代码Java代码 Platform.getLog(Platform.getBundle(bundleID)).log(newStatus(serverity, bundleID, code, message, t));Platform.getLog(Platform.getBundle(bundleID)).log(new Status(serverity, bundleID, code, message, t));原理知道了那么怎么样得到像eclipse生成.log里的那些效果呢runtime包下有个Status类它继承IStatus大家可以去看看它的源码我说到它的原因就是因为它包含了eclipse的warning,error以及info这三类log都是最常用的下面我也不啰嗦了贴代码Java代码 packagecom.bjgtt.msap.workbench.utilities;importorg.eclipse.core.runtime.Platform;importorg.eclipse.core.runtime.Status;publicclassLogUtil {publicstaticvoidlogError(Throwable t) {logError(null, t.getMessage(), t);}publicstaticvoidlogError(String bundleID, Throwable t) {logError(bundleID, t.getMessage(), t);}publicstaticvoidlogError(String bundleID, String message, Throwable t) {log(bundleID, message, t, Status.ERROR, Status.OK);}publicstaticvoidlogWarning(String message) {log(null, message,null, Status.WARNING, Status.OK);}publicstaticvoidlogError(String bundleID, String message) {logError(bundleID, message,null);}publicstaticvoidlog(String bundleID, String message, Throwable t,intserverity,intcode) {if(bundleID null) {bundleID Activator.getDefault().getBundle().getSymbolicName();}Platform.getLog(Platform.getBundle(bundleID)).log(newStatus(serverity, bundleID, code, message, t));}}package com.bjgtt.msap.workbench.utilities;import org.eclipse.core.runtime.Platform;import org.eclipse.core.runtime.Status;public class LogUtil {public static void logError(Throwable t) {logError(null, t.getMessage(), t);}public static void logError(String bundleID, Throwable t) {logError(bundleID, t.getMessage(), t);}public static void logError(String bundleID, String message, Throwable t) {log(bundleID, message, t, Status.ERROR, Status.OK);}public static void logWarning(String message) {log(null, message, null, Status.WARNING, Status.OK);}public static void logError(String bundleID, String message) {logError(bundleID, message, null);}public static void log(String bundleID, String message, Throwable t, int serverity, int code) {if (bundleID null) {bundleID Activator.getDefault().getBundle().getSymbolicName();}Platform.getLog(Platform.getBundle(bundleID)).log(new Status(serverity, bundleID, code, message, t));}}大家看到了上面的类中有六个方法归根到底都是调的最下面的方法所以代码就变得简单多了为大家介绍这些方法的使用吧首先就是logError(Throwable t)方法Error很显然就是捕获的异常信息了logError(String bundleID, Throwable t) 有上面的方法了这个方面就用不着了接着就是logError(String bundleID, String message, Throwable t)方法了用了组装错误消息logWarning(String message) 看名字大家就知道是告警日志了最常用的地方就是你需要得到一个对象的实例而这个实例为null那么你就可以使用这个方法来记录日志了logError(String bundleID, String message) 插件错误信息bundleID就是你的插件ID