Difference between revisions of "Xtext Project Plan/Features/Logging"
(→How do I use Logging in Xtext?) |
|||
Line 2: | Line 2: | ||
=== How do I use Logging in Xtext? === | === How do I use Logging in Xtext? === | ||
+ | |||
+ | * Add org.eclipse.xtext.log4j to the manifest of your bundle: | ||
+ | org.eclipse.xtext.log4j;bundle-version="1.2.15" | ||
+ | * Register your bundle as a buddy to org.eclipse.xtext.log4j | ||
+ | Eclipse-RegisterBuddy: org.eclipse.xtext.log4j | ||
+ | * Add your bundle to the loggermap (located in org.eclipse.xtext.logging/plugin.xml): | ||
+ | <mapentry | ||
+ | bundleId="org.eclipse.xtext" | ||
+ | loggername="org\.eclipse\.xtext\..*"> | ||
+ | </mapentry> | ||
+ | |||
+ | * After those preparatory steps, you can now call the logger API: | ||
+ | log.debug("Starting Xtext UI bundle."); | ||
== Developer Information == | == Developer Information == |
Revision as of 09:56, 29 July 2008
Contents
User Information
How do I use Logging in Xtext?
- Add org.eclipse.xtext.log4j to the manifest of your bundle:
org.eclipse.xtext.log4j;bundle-version="1.2.15"
- Register your bundle as a buddy to org.eclipse.xtext.log4j
Eclipse-RegisterBuddy: org.eclipse.xtext.log4j
- Add your bundle to the loggermap (located in org.eclipse.xtext.logging/plugin.xml):
<mapentry bundleId="org.eclipse.xtext" loggername="org\.eclipse\.xtext\..*"> </mapentry>
- After those preparatory steps, you can now call the logger API:
log.debug("Starting Xtext UI bundle.");
Developer Information
Required Features
- completely transparent logging
- use same logger API in frontend and backend / IDE vs standalone mode
- levels WARN, ERROR and FATAL will be logged to the Eclipse Error Log
Researched options
The followng options were researched:
- Commons Logging (not feasible due to the fact only ONE configuration can be used throughout the ENTIRE application)
- Log4J bundle from the Eclipse Orbit (still, only one bundle can configure the Log system)
Solution
- Use Log4j, but create a custom Log4j bundle (org.eclipse.xtext.log4j)
- org.eclipse.xtext.logging contains EclipseLogAppender
- Mapping from logger name to Eclipse bundle is achieved by extending the extension point org.eclipse.xtext.logging.loggermap (loggername contains a regex) :
<extension point="org.eclipse.xtext.logging.loggermap"> <mapentry bundleId="org.eclipse.xtext" loggername="org\.eclipse\.xtext\..*"> </mapentry> <mapentry bundleId="org.eclipse.xtext.reference.ui" loggername="org\.eclipse\.xtext\.reference\.ui\..*"> </mapentry> <mapentry bundleId="org.eclipse.xtext.ui" loggername="org\.eclipse\.xtext\.ui\..*"> </mapentry> </extension>