如何为你的RCP增加日志功能
2006-05-15 08:21
507 查看
The Eclipse runtime plug-in provides a simple set of APIs for logging exceptions, warnings, or other information useful in debugging or servicing a deployed Eclipse product. The intent of the log is to record information that can be used later to diagnose problems in the field. Because this information is not directed at users, you do not need to worry about translating messages or simplifying explanations into a form that users will understand. The idea is that when things go wrong in the field, your users can send you the log file to help you figure out what happened.
Each plug-in has its own log associated with it, but all logged information eventually makes its way into the platform log file (see the getLogFileLocation method on Platform). The log for a plug-in is accessed from the plug-in’s class, using getLog inherited from Plugin. You can attach a listener to an individual log or to the platform log if you are interested in receiving notification of logged events. Use addLogListener on either Platform or the result of Plugin.getLog().
You can write any kind of IStatus object to the log file, including a MultiStatus if you have hierarchies of information to display. If you create your own subclass of the utility class Status, you can override the getMessage method to return extra information to be displayed in the log file. Many plug-ins add convenience methods to their plug-in class for writing messages and errors to the log:
During development, you can browse and manipulate the platform log file using the PDE Error Log view (Window > Show View > Other > PDE Runtime > Error Log). You can also have the log file mirrored in the Java console by starting Eclipse with the -consoleLog command-line argument.
We explicitly pass the VM because on Windows you have to use java.exe instead of javaw.exe if you want the Java console window to appear.
Each plug-in has its own log associated with it, but all logged information eventually makes its way into the platform log file (see the getLogFileLocation method on Platform). The log for a plug-in is accessed from the plug-in’s class, using getLog inherited from Plugin. You can attach a listener to an individual log or to the platform log if you are interested in receiving notification of logged events. Use addLogListener on either Platform or the result of Plugin.getLog().
You can write any kind of IStatus object to the log file, including a MultiStatus if you have hierarchies of information to display. If you create your own subclass of the utility class Status, you can override the getMessage method to return extra information to be displayed in the log file. Many plug-ins add convenience methods to their plug-in class for writing messages and errors to the log:
import org.eclipse.core.runtime.Status; ... public void log(String msg) { log(msg, null); } public void log(String msg, Exception e) { getLog().log(new Status(Status.INFO, myPluginID, Status.OK, msg, e)); }
During development, you can browse and manipulate the platform log file using the PDE Error Log view (Window > Show View > Other > PDE Runtime > Error Log). You can also have the log file mirrored in the Java console by starting Eclipse with the -consoleLog command-line argument.
eclipse -vm c:/jre/bin/java.exe -consoleLog
We explicitly pass the VM because on Windows you have to use java.exe instead of javaw.exe if you want the Java console window to appear.
相关文章推荐
- 为你的代码增加日志功能
- 如何用开源经历为你的简历增加光彩
- 网站如何让用户主动为你增加流量 推荐
- 如何使用log4j设置tomcat 5.5版本的的日志功能
- 第16章 增加日志功能
- 用C/C++扩展你的PHP 为你的php增加功能
- 阅读《大型网站技术架构》第五、六、七章,结合我们的系统,分析如何增加相应的功能,提高系统的可用性和易用性。
- 如何给自己的eclipse插件增加trace功能
- BASH增加日志功能
- 分析如何增加相应的功能来提高系统的可用性和易用性
- 请教各位仁兄 ,如何给delphi7增加gdi+的功能?
- 如何启用Open vSwitch的日志功能以便调试和排障
- Sql2012如何将远程服务器数据库及表、表结构、表数据导入本地数据库 自定义日志记录功能,按日记录,很方便 C#常量和字段以及各种方法的语法总结 类型,对象,线程栈,托管堆在运行时的关系,以及clr如何调用静态方法,实例方法,和虚方法 asp.net webapi 自定义身份验证
- 从头认识Spring-3.3 简单的AOP日志实现-增加检查订单功能
- Mysql:开启了二进制日志功能 log-bin 的mysql数据库, 如何故障恢复?
- PDF文件如何增加书签功能
- 如何使用系统自带的日志转储功能logroate.存放应用日志
- 利用Spring AOP与action注解为系统增加日志功能
- 如何为你的WindowsPhone应用添加市场评分功能
- 如何为fckeditor文本编辑器增加图片删除功能