Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ How do I use the platform logging facility?"

m (See Also:: Fixing the wikilink)
m
Line 7: Line 7:
 
is that when things go wrong in the field, your users can send you the log file to
 
is that when things go wrong in the field, your users can send you the log file to
 
help you figure out what happened.
 
help you figure out what happened.
 
 
  
 
Each plug-in has its own log associated with it, but all logged information eventually
 
Each plug-in has its own log associated with it, but all logged information eventually
Line 17: Line 15:
 
in receiving notification of logged events.  Use <tt>addLogListener</tt> on either
 
in receiving notification of logged events.  Use <tt>addLogListener</tt> on either
 
<tt>Platform</tt> or the result of <tt>Plugin.getLog()</tt>.
 
<tt>Platform</tt> or the result of <tt>Plugin.getLog()</tt>.
 
 
  
 
You can write any kind of <tt>IStatus</tt> object
 
You can write any kind of <tt>IStatus</tt> object
Line 38: Line 34:
 
   }
 
   }
 
</pre>
 
</pre>
 
 
 
  
 
During development, you can browse and manipulate the platform log file
 
During development, you can browse and manipulate the platform log file
Line 51: Line 44:
 
We explicitly pass the VM because on Windows you  have to use <tt>java.exe</tt>  
 
We explicitly pass the VM because on Windows you  have to use <tt>java.exe</tt>  
 
instead of <tt>javaw.exe</tt> if you want the Java console window to appear.
 
instead of <tt>javaw.exe</tt> if you want the Java console window to appear.
 
 
 
 
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ Where can I find that elusive .log file?]]
  
 
+
{{Template:FAQ_Tagline}}
[[FAQ Where can I find that elusive .log file?]]
+
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

Revision as of 22:47, 1 June 2006

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&#146;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.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.