Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Xtext Project Plan/Features/Logging"

(How do I use Logging in Xtext?)
 
Line 1: Line 1:
== User Information ==
+
== Logging ==
  
=== How do I use Logging in Xtext? ===
+
Logging has been refactored for Xtext (since Helios 0.8.0 M2).
 
+
In order to customize the configuration, you'll have to contribute a fragment to org.apache.log4j and make sure that no other fragments exist. Just put a log4j.properties into the src/ of that fragment and you're done.
* 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>
+

Latest revision as of 04:52, 24 August 2009

Logging

Logging has been refactored for Xtext (since Helios 0.8.0 M2). In order to customize the configuration, you'll have to contribute a fragment to org.apache.log4j and make sure that no other fragments exist. Just put a log4j.properties into the src/ of that fragment and you're done.

Back to the top