Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xtext] Logging in Xtext
[xtext] Logging in Xtext [message #26468] Fri, 23 January 2009 08:58 Go to next message
Madhu Samuel is currently offline Madhu Samuel
Messages: 199
Registered: July 2009
Senior Member
Hi Sven,

I have a question regarding the logging strategy used in xtext. I went
through the webpage @
http://wiki.eclipse.org/Xtext_Project_Plan/Features/Logging

Its a 3 step process to install the logger.

ie,
1. Add a dependency from MyPlugin to log4j plugin
2. Register my plugin as a buddy for log4j plugin
3. Add my plugin to the logger map

What is the significance of this strategy? Even if you use only the first
step, ie, "add a dependency from MyPlugin to log4j plugin", still you can
work with the log4j logger without any issues.

Can you please explain the reason for such an implementation.

Thanks again,
Madhu


Re: [xtext] Logging in Xtext [message #26697 is a reply to message #26468] Mon, 26 January 2009 10:04 Go to previous message
Peter Friese is currently offline Peter Friese
Messages: 30
Registered: July 2009
Member
Madhu,

comments below.

Madhu Samuel <madhu.samuel@in.bosch.com> wrote:

> I have a question regarding the logging strategy used in xtext. I
went
> through the webpage @
> http://wiki.eclipse.org/Xtext_Project_Plan/Features/Logging

> Its a 3 step process to install the logger.

> ie,
> 1. Add a dependency from MyPlugin to log4j plugin
> 2. Register my plugin as a buddy for log4j plugin
> 3. Add my plugin to the logger map
>
> What is the significance of this strategy? Even if you use only the
> first step, ie, "add a dependency from MyPlugin to log4j plugin",
> still you can work with the log4j logger without any issues.

> Can you please explain the reason for such an implementation.

The reasons for this design are described here: http://
wiki.eclipse.org/Xtext_Project_Plan/Features/
Logging#Developer_Information, but let me briefly reiterate.
We wanted to have a transparent logging facility that works both in the
Xtext UI and in the Xtext backend. Additionally, we wanted to be able
to redirect all messages in levels WARN, ERROR and FATAL to the Eclipse
error log.

To achieve this, we did the following:
1) we created our own copy of Log4j that has "BuddyPolicy: registered"
set so it can see the classpath of all other bundles that register
themselves to our Log4J bundle. This is needed so that we can configure
Log4J using a properties file *inside our very own bundles*.
2) we created a Log4J appender
(org.eclipse.xtext.logging.EclipseLogAppender) that can write to the
Eclipse error log. This appender of course is only needed when you're
running inside Eclipse in UI mode.
3) Introduced a way to map class names to bundles (using the logger
map). This is needed since you cannot determine from which bundle a
logger call has been received. So we need to translate class names to
bundle names in our appender. This is actually only eye candy.

Cheers,
Peter


--
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo
Previous Topic:[TCS] A simple expression language with TCS?
Next Topic:[TCS} source access
Goto Forum:
  


Current Time: Sun Oct 26 01:16:03 GMT 2014

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

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