Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Eclipse logging and Log4J
Eclipse logging and Log4J [message #302305] Wed, 19 April 2006 03:28 Go to next message
Eclipse UserFriend
Originally posted by: k.wigboldus.wisdom.nl

Is it possible to redirect the eclipse logging (which is default written
to a .log file) to (for example) Log4J?

I am looking for a solution to get the logging of my eclipse plugin
(including logging generated by eclipse core) and the logging generated by
a jar file (which I use in my plugin) into one logging file.
Re: Eclipse logging and Log4J [message #302328 is a reply to message #302305] Wed, 19 April 2006 08:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Create the class below and but in your Plugin startup code this:

<code>
Platform.addLogListener(new EclipseToLog4J());
</code>

Its only a quick hack. The comments are in German, sorry.

This is the logging class:
<code>
public class EclipseToLog4J implements ILogListener {

private static final String PREFIX = "eclipse.";

/** Hier werden die Loggers gecacht. Key ist der pluginnamen ohne den Prefix */
private Map loggers = new HashMap();


/**
* Gibt das Logging Event von Eclipse auf log4j aus.
* Als Loggernamen wird "eclipse." plus den Pluginnamen genommmen.
*
* @param status das Logging Event
* @param plugin Name des Plugins, welches die Ausgabe verursacht hat
*/
public void logging(IStatus status, String plugin) {
Logger log = (Logger) loggers.get(plugin);
if (log == null) {
// Noch nicht angelegt
log = Logger.getLogger(PREFIX + plugin);
loggers.put(plugin, log);
}

Priority prio = Priority.INFO; // OK, cancle usw --> Info
if ((status.getSeverity() & IStatus.ERROR) != 0) {
prio = Priority.ERROR;
} else if ((status.getSeverity() & IStatus.WARNING) != 0) {
prio = Priority.WARN;
}
if (log.isEnabledFor(prio)) {
log.log(prio, status.getMessage(), status.getException());
}
}
</code>
Re: Eclipse logging and Log4J [message #302376 is a reply to message #302305] Wed, 19 April 2006 14:43 Go to previous message
Eclipse UserFriend
Originally posted by: hansm.science.uva.nlDELETE

In article <db354c55bbe60e2b76992bca8d5fc9e4$1@www.eclipse.org>,
k.wigboldus@wisdom.nl (Kor) wrote:

> Is it possible to redirect the eclipse logging (which is default written
> to a .log file) to (for example) Log4J?
>
> I am looking for a solution to get the logging of my eclipse plugin
> (including logging generated by eclipse core) and the logging generated by
> a jar file (which I use in my plugin) into one logging file.

You might have a look at the article "Universal Logger Plug-ins for RCP
Applications" from John Franey. You can find it through www.eclipsezone.com.

Hans van der Meer
Previous Topic:Automate Build Process
Next Topic:Get editor for file
Goto Forum:
  


Current Time: Fri Sep 19 00:11:04 EDT 2025

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

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

Back to the top