How to add log messages in Eclipse log file. [message #307985] |
Thu, 07 September 2006 09:11  |
Eclipse User |
|
|
|
Originally posted by: priya_kothari.persistent.co.in
Hi,
I want to add my plugin debug messages to the Eclipse log that gets created
in the .metdata directory. I tried using Logger from java.util package but
it does not add them in the log file.
Any pointers would be of great help.
~Priya
|
|
|
|
|
Re: How to add log messages in Eclipse log file. [message #307988 is a reply to message #307987] |
Thu, 07 September 2006 09:47  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------090505060303080109070705
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Priya,
You can create a Status object. Here's how EMF uses the log:
public void log(Object logEntry)
{
IStatus status;
if (logEntry instanceof IStatus)
{
status = (IStatus)logEntry;
getLog().log(status);
}
else
{
if (logEntry == null)
{
logEntry = new
RuntimeException(getString("_UI_NullLogEntry_exception",
true)).fillInStackTrace();
}
if (logEntry instanceof Throwable)
{
Throwable throwable = (Throwable)logEntry;
// System.err.println("Logged throwable:
--------------------");
// throwable.printStackTrace();
String message = throwable.getLocalizedMessage();
if (message == null)
{
message = "";
}
getLog().log(new Status(IStatus.WARNING,
getBundle().getSymbolicName(), 0, message, throwable));
}
else
{
// System.err.println("Logged throwable:
--------------------");
// throwable.printStackTrace();
getLog().log (new Status (IStatus.WARNING,
getBundle().getSymbolicName(), 0, logEntry.toString(), null));
}
}
}
}
Priya wrote:
> Hi,
>
> Can you give me more details about this? I tried doing it, I got handle to
> ILog, but it needs IStatus as a parameter.
> But if I want to log some value of a variable in the log file, there is no
> method where I can do a setMessage or pass my message as a parameter.
> Is it possbile to do this?
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:edp6i3$uld$1@utils.eclipse.org...
>
>> Priya,
>>
>> Use Plugin.getLog() to get the ILog you can use to log messages to the
>> error log.
>>
>>
>> Priya wrote:
>>
>>> Hi,
>>>
>>> I want to add my plugin debug messages to the Eclipse log that gets
>>> created in the .metdata directory. I tried using Logger from java.util
>>> package but it does not add them in the log file.
>>>
>>> Any pointers would be of great help.
>>>
>>> ~Priya
>>>
>>>
>>>
>>>
>>>
>
>
>
--------------090505060303080109070705
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Priya,<br>
<br>
You can create a Status object. Here's how EMF uses the log:<br>
<blockquote><small> public void log(Object logEntry)</small><br>
<small> {</small><br>
<small> IStatus status;</small><br>
<small> if (logEntry instanceof IStatus)</small><br>
<small> {</small><br>
<small> status = (IStatus)logEntry;</small><br>
<small> getLog().log(status);</small><br>
<small> }</small><br>
<small> else </small><br>
<small> {</small><br>
<small> if (logEntry == null)</small><br>
<small> {</small><br>
<small> logEntry = new
RuntimeException(getString("_UI_NullLogEntry_exception",
true)).fillInStackTrace();</small><br>
<small> }</small><br>
<br>
<small> if (logEntry instanceof Throwable)</small><br>
<small> {</small><br>
<small> Throwable throwable = (Throwable)logEntry;</small><br>
<br>
<small> // System.err.println("Logged throwable:
--------------------");</small><br>
<small> // throwable.printStackTrace();</small><br>
<br>
<small> String message = throwable.getLocalizedMessage();</small><br>
<small> if (message == null)</small><br>
<small> {</small><br>
<small> message = "";</small><br>
<small> }</small><br>
<br>
<small> getLog().log(new Status(IStatus.WARNING,
getBundle().getSymbolicName(), 0, message, throwable));</small><br>
<small> }</small><br>
<small> else</small><br>
<small> {</small><br>
<small> // System.err.println("Logged throwable:
--------------------");</small><br>
<small> // throwable.printStackTrace();</small><br>
<br>
<small> getLog().log (new Status (IStatus.WARNING,
getBundle().getSymbolicName(), 0, logEntry.toString(), null));</small><br>
<small> }</small><br>
<small> }</small><br>
<small> } </small><br>
<small> }</small><br>
</blockquote>
<br>
<br>
<br>
Priya wrote:
<blockquote cite="midedp7ai$7sc$1@utils.eclipse.org" type="cite">
<pre wrap="">Hi,
Can you give me more details about this? I tried doing it, I got handle to
ILog, but it needs IStatus as a parameter.
But if I want to log some value of a variable in the log file, there is no
method where I can do a setMessage or pass my message as a parameter.
Is it possbile to do this?
"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com"><merks@ca.ibm.com></a> wrote in message
<a class="moz-txt-link-freetext" href="news:edp6i3$uld$1@utils.eclipse.org">news:edp6i3$uld$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Priya,
Use Plugin.getLog() to get the ILog you can use to log messages to the
error log.
Priya wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
I want to add my plugin debug messages to the Eclipse log that gets
created in the .metdata directory. I tried using Logger from java.util
package but it does not add them in the log file.
Any pointers would be of great help.
~Priya
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
--------------090505060303080109070705--
|
|
|
Powered by
FUDForum. Page generated in 0.39639 seconds