Add the error log view to your Eclipse RCP application
The Eclipse platform provide error message in case something goes wrong.
During development I use the launch parameter -consoleLog to see if any error has occured. I assume most plugin developer use -consoleLog that is why I opened Bug for making -consoleLog a default in a new launch configuration.
Obviously you don’t want your users to check the console for errors. To make errors visible to the user you can add the exiting error log to your RCP application.
Create a new Eclipse RCP project “de.vogella.rcp.intro.errorview” for this purpose. Use the “Hello RCP” as a template.
Select the plugin.xml and add the dependency to org.eclipse.ui.views.log.
Ddd the standard Eclipse command “org.eclipse.ui.views.showView” to your menu under the Entry “Admin”. See Eclipse Commands how to do this.
This will result in the following plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="application"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="de.vogella.rcp.intro.errorview.Application">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="RCP Perspective"
class="de.vogella.rcp.intro.errorview.Perspective"
id="de.vogella.rcp.intro.errorview.perspective">
</perspective>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu">
<menu
label="Admin">
<command
commandId="org.eclipse.ui.views.showView"
label="Show Error View"
style="push">
<parameter
name="org.eclipse.ui.views.showView.viewId"
value="org.eclipse.pde.runtime.LogView">
</parameter>
</command>
</menu>
</menuContribution>
</extension>
</plugin>
Run your new application. You should have a menu entry “Admin” with an entry “Show Error View”. If you select it the error view should open.
Filed under: Eclipse

August 17th, 2009 at 10:57 pm
all true. Is there anything that log view is missing from RCP consumers point of view?
August 17th, 2009 at 11:11 pm
@Jacek Not that I’m aware of
September 2nd, 2009 at 8:00 am
Any examples on how to use/fill the error log?
September 2nd, 2009 at 8:14 am
@Martin: if you have for example an exception it will be shown in the error view
September 3rd, 2009 at 1:46 pm
I would like to fill the log view with my own log messages, I have found something like:
Status status = new Status(IStatus.INFO,”Test”,”Test string!”);
WorkbenchPlugin.log(status);
but I get some warnings:
Multiple markers at this line
- Discouraged access: The method log(IStatus) from the type WorkbenchPlugin is not accessible due to restriction on required library C:\Programme
\eclipse\plugins\org.eclipse.ui.workbench_3.4.2.M20090127-1700.jar
- Discouraged access: The type WorkbenchPlugin is not accessible due to restriction on required library C:\Programme\eclipse\plugins
\org.eclipse.ui.workbench_3.4.2.M20090127-1700.jar
so how should i access the log view?
September 3rd, 2009 at 2:21 pm
@Martin: I had a similar problem. I posted a question to this topic but the only answer I got was that I should turn of the corresponding check:
http://dev.eclipse.org/newslists/news.eclipse.platform.pde/msg02084.html
September 6th, 2009 at 12:04 am
I used the logger with:
Activator.getDefault().getLog().log(status);
and all messages are shown in the logView.
Is there a way to avoid, the View jumps to foreground?
September 6th, 2009 at 8:07 am
@Uwe Not sure what you mean; if the view is not open is also will not be displayed if messages get added to the view.
September 6th, 2009 at 10:45 am
Thats right. My intention was to have another view in the foreground but log all messages in the background. A solution could be to use the log view as fast view. Is this possible with an RCP application?
September 6th, 2009 at 12:59 pm
@Uwe Yes this is possible. For the general concept please see here: http://www.vogella.de/articles/RichClientPlatform/article.html If the view should be a fast view, just use “relationship” “fast” in the perspectiveExtension
September 14th, 2009 at 10:12 pm
@Uwe: You also have to enable the fast view pane in ApplicationWorkbenchWindowAdvisor via configurer.setShowFastViewBars(true); in method preWindowOpen()
September 15th, 2009 at 7:04 pm
[...] Fast Views in Eclipse RCP No Comments by Lars Vogel / September 15th, 2009 In Adding the error view to RCP application one commenter asked how he could add a view as a fast view to an Eclipse RCP [...]
November 2nd, 2009 at 5:10 am
Hello,
I was wondering if there’s a way to modify the error log view so that it can, for example, be in other language. I speak spanish and the application I’m developing is going to be in spanish too, since I need a view pretty much similar to the Error Log View (with a small changes, besides the language) I thought that maybe there could be a way to obtain the source code of the view and change according to my need. Could you tell me if that’s possible? Thank you
November 2nd, 2009 at 10:50 am
@Fernando yes, you can get the source code and modify it. See http://www.vogella.de/articles/EclipseCodeAccess/article.html for a guide to access the source code of Eclipse. To find the code of the view you can use the Plugin Spy.
November 2nd, 2009 at 3:15 pm
Thanks a lot. Now, since I want to modify it, of course I shouldn’t import the binaries, but the source folders instead. Is there any legal prohibition for modifying the source code of standard eclipse views and use it as part of my Eclipse RCP application?
Another question (and I know it must sound a little stupid). What I should do next is modify this source code obtained and, since it is already a plug in, add it to my project and used it right. Should I change the name of it? (again por legal reasons?).
Thanks again.
November 2nd, 2009 at 3:20 pm
@Fernando I’m not an legal expert but as far as I now the EPL allow you to do what you want.
November 2nd, 2009 at 3:35 pm
Ok, thanks!
December 16th, 2009 at 3:23 am
This does not seem to work with eclipse 3.6, just to let you know.
December 16th, 2009 at 4:54 am
@Michael: What is the problem with Eclipse 3.6?
March 26th, 2010 at 9:32 am
I am regular user of your inputs. Thanks
I was wondering, instead of error view [which will scare the hell out of my customers], I would like to catch all the exceptions on my client.log file. Every now and then I get an instance where the client seems to poof out and when I go to their location and look for .metadata/.log I see some exception. How can I avoid such cases or at least catch these “out of the blue” exceptions on my log file. I email this to myself at the end of day.
Thanks.
Shyam.
March 28th, 2010 at 6:45 pm
@Shyam: Sorry but I have not done such a thing.
March 31st, 2010 at 10:08 am
Any idea how to avoid seeing all Log views (e.g. Bookmarks) in ContributionItemFactory.VIEWS_SHORTLIST, e.g. Window | Show View…?
April 1st, 2010 at 5:53 pm
@Nick you can just use your own command to show the view: http://www.vogella.de/articles/EclipseCommands/article.html
October 15th, 2010 at 1:12 pm
When i added a dependency to org.eclipse.ui.views.log and from code i wanted to show the Error view
addView(
“org.eclipse.pde.runtime.LogView”
, IPageLayout.BOTTOM
, 0.75f
, “SomeViewID”
);
But as long as the dependency is there i get error java.lang.RuntimeException: No application id has been found.
The moment i remove this dependency my application runs fine. Any suggestions ?
October 15th, 2010 at 3:43 pm
@Mahesh I suggest to add this plugin to your launch configuration.