Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to add log messages in Eclipse log file.
How to add log messages in Eclipse log file. [message #307985] Thu, 07 September 2006 09:11 Go to next message
Eclipse UserFriend
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 #307986 is a reply to message #307985] Thu, 07 September 2006 09:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

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
>
>
>
>
Re: How to add log messages in Eclipse log file. [message #307987 is a reply to message #307986] Thu, 07 September 2006 09:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: priya_kothari.persistent.co.in

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
>>
>>
>>
>>
Re: How to add log messages in Eclipse log file. [message #307988 is a reply to message #307987] Thu, 07 September 2006 09:47 Go to previous message
Eclipse UserFriend
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.&nbsp; Here's how EMF uses the log:<br>
<blockquote><small>&nbsp;&nbsp;&nbsp; public void log(Object logEntry)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IStatus status;</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (logEntry instanceof IStatus)</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; status = (IStatus)logEntry;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; getLog().log(status);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else </small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (logEntry == null)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logEntry = new
RuntimeException(getString("_UI_NullLogEntry_exception",
true)).fillInStackTrace();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (logEntry instanceof Throwable)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Throwable throwable = (Throwable)logEntry;</small><br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // System.err.println("Logged throwable:
--------------------");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // throwable.printStackTrace();</small><br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String message = throwable.getLocalizedMessage();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (message == null)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message = "";</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; getLog().log(new Status(IStatus.WARNING,
getBundle().getSymbolicName(), 0, message, throwable));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // System.err.println("Logged throwable:
--------------------");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // throwable.printStackTrace();</small><br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; getLog().log (new Status (IStatus.WARNING,
getBundle().getSymbolicName(), 0, logEntry.toString(), null));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; } </small><br>
<small>&nbsp; }</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">&lt;merks@ca.ibm.com&gt;</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--
Previous Topic:PDE headless build (3.2) - Bundle as single jar - not working
Next Topic:headless ant task
Goto Forum:
  


Current Time: Tue Jul 15 23:21:02 EDT 2025

Powered by FUDForum. Page generated in 0.39639 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top