Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Logger in RCP model
Logger in RCP model [message #452715] Thu, 13 July 2006 13:39 Go to next message
Igor Semenko is currently offline Igor SemenkoFriend
Messages: 14
Registered: July 2009
Junior Member
Hi, I'm new to RCP and I would like to know how do you guys log messages within your model classes?

The problem is that I don't want to introduce dependency on the MyPlugin.getLog() (and therefore Eclipse platform) into generic model classes. If I just use Log4j and Logger.getInstance() - I'm in trouble redirecting Log4j's messages into proper location.

There is a nice article on this topic ( http://www-128.ibm.com/developerworks/opensource/library/os- eclog/), but this would again wire my model to something like MyPlugin.getLogManager.getLogger().

There is also possiblity to inject Logger into model classes, but this is 'too much' for this problem.
Re: Logger in RCP model [message #452716 is a reply to message #452715] Thu, 13 July 2006 13:47 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
did you look at RuntimeLog.log(status);

Tom

Igor Semenko wrote:
> Hi, I'm new to RCP and I would like to know how do you guys log messages within your model classes?
>
> The problem is that I don't want to introduce dependency on the MyPlugin.getLog() (and therefore Eclipse platform) into generic model classes. If I just use Log4j and Logger.getInstance() - I'm in trouble redirecting Log4j's messages into proper location.
>
> There is a nice article on this topic ( http://www-128.ibm.com/developerworks/opensource/library/os- eclog/), but this would again wire my model to something like MyPlugin.getLogManager.getLogger().
>
> There is also possiblity to inject Logger into model classes, but this is 'too much' for this problem.
Re: Logger in RCP model [message #452746 is a reply to message #452716] Thu, 13 July 2006 14:39 Go to previous messageGo to next message
Igor Semenko is currently offline Igor SemenkoFriend
Messages: 14
Registered: July 2009
Junior Member
RuntimeLog.log() has "discouraged access" warning, so doesn't look as a proper approach either.

Igor.
Re: Logger in RCP model [message #452748 is a reply to message #452746] Thu, 13 July 2006 15:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Ok and what's with:

Platform.getLog(bundle);

Tom

Igor Semenko wrote:
> RuntimeLog.log() has "discouraged access" warning, so doesn't look as a proper approach either.
>
> Igor.
Re: Logger in RCP model [message #452749 is a reply to message #452748] Thu, 13 July 2006 15:31 Go to previous messageGo to next message
Igor Semenko is currently offline Igor SemenkoFriend
Messages: 14
Registered: July 2009
Junior Member
Wouldn't this unnecessary wire model class (say Engine) to the Eclipse platform again? I will have to get bundle from MyPlugin. I would not like to introduce such a dependency.

Igor
Re: Logger in RCP model [message #452752 is a reply to message #452715] Thu, 13 July 2006 17:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

Igor Semenko wrote:

> Hi, I'm new to RCP and I would like to know how do you guys log messages
> within your model classes?
>
> The problem is that I don't want to introduce dependency on the
> MyPlugin.getLog() (and therefore Eclipse platform) into generic model
> classes. If I just use Log4j and Logger.getInstance() - I'm in trouble
> redirecting Log4j's messages into proper location.
>
> There is a nice article on this topic
> ( http://www-128.ibm.com/developerworks/opensource/library/os- eclog/), but
> this would again wire my model to something like
> MyPlugin.getLogManager.getLogger().
>
> There is also possiblity to inject Logger into model classes, but this is
> 'too much' for this problem.

I think your stuck. Eclipse has its own logging architecture. You can
choose to instead use your own logging in eclipse. If you do, then you can
choose to use the same logging that you use in your model classes.

I too have divided my model classes out into their own plugin and they do
not call on _any_ eclipse methods. That plugin does not import any eclipse
packages IIRC. I have not put logging into it but the plan was to probably
use Java's Logger. However, one of the libraries I use uses log4J... Its
a headache. Everybody logs for himself. You would end up dividing the
logging by layers anyway. Just annoying that each layer would use a
different library.


--
Respectfully,

CL Gilbert
"Verily, verily, I say unto you, He that entereth not by the door() into the
sheepfold{}, but climbeth up some other *way, the same is a thief and a
robber."
Re: Logger in RCP model [message #452795 is a reply to message #452749] Sat, 15 July 2006 07:15 Go to previous message
Mike Evans is currently offline Mike EvansFriend
Messages: 237
Registered: July 2009
Senior Member
On Thu, 13 Jul 2006 11:31:57 EDT, Igor Semenko wrote:

> Wouldn't this unnecessary wire model class (say Engine) to the Eclipse platform again? I will have to get bundle from MyPlugin. I would not like to introduce such a dependency.
>
> Igor

I am guessing that your model classes are fairly behaviour-rich (as opposed
to being glorified beans) which is why you wish to log within them.

As you imply, best practice is to keep model classes completely 'clean'.
As the RCP platform offers neither dependency injection (e.g. Spring) or
aspects (e.g AspectJ) another alternative is to wrap all your model classes
within adapters that allow them to integrate with the platform. This is my
approach and for a bit of up-front work I have found it to be very, very
useful for linking a 'pure' model to the GUI. This is also how I have done
trace-style logging for my model components.


--
Mike E.
Previous Topic:Best practice for platform dependent plugin
Next Topic:Product export fails due to dependency cycle
Goto Forum:
  


Current Time: Sun Oct 06 20:04:39 GMT 2024

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

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

Back to the top