[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Re: Logging

Rudolf,
the common way is to use statushandlers. There is a document about this on Wiki: http://wiki.eclipse.org/Platform_UI_Error_Handling
It's generally about traveling of statuses. You can get a status (eg. if you catch CoreException, then coreException.getStatus) or eventually throw your own, in any crisis or success situation.
To handle a status you call StatusManager.getDefault.handle(...);
So it looks easy and is easy. The way, how statuses are handled (error dialog, only log, etc.) can either be suggested directly with a style in handle(status, style) method or customized by creating your own status handler and registering under org.eclipse.ui.statusHandlers extension point.
Status contains a name of originating plugin, message, status code and a Throwable if it applies. Statuses can also be grouped eg. if they are all related to one issue.
There is also a service at lower lever - in Equinox - (org.eclipse.equinox.log) to which you can register to catch up and eventually process any errors, but this plugin has to be downloaded separately from Equinox.


Of course you can still use log4j in your plugins, and afaik some people do this, but it offers something quite different, so I guess which one you choose will mainly depend on what you really need.

Rudolf Ziegaus wrote:
Hello,

I hope this question is not too general and OT: what is the preferred way
to log information in plugins? I thought about using log4j, but I am also
open to different solutions if it's standard for Eclipse.

WOuld be great if you could point me to some documents, how to do the
logging.


TIA,

Rudi