Working with the Common Logging sample

This sample demonstrates the use of the Common Logging implementation in an Eclipse environment by logging records in a Common Logging Sample plug-in. You can create and configure Eclipse log records (for example, IStatus) and Common Base Event log records. Then you can log the newly created log records through a plug-in's logger configured for writing to the Common.Logging.Logger Logging Agent and the Eclipse Common Logging XML log file (workspace/.metadata/CommonBaseEvents.xml). The Common.Logging.Logger Logging Agent may be monitored by the workbench using the Agent Controller service or daemon.

To add the sample to your workspace:

  1. Select File > New > Project.
  2. In the New Project wizard, select Examples > Common Logging > Common Logging Sample.
  3. Click Next to see the project name and location, optionally changing them from the defaults provided.
  4. Click Finish.

Prerequisites

JRE 1.4.0 or above is required to compile and run this sample.

The following JAR files are required for running the sample:

JAR file name Plug-in that contains the JAR Reason for the requirement
com.ibm.etools.common.logging.jar com.ibm.etools.common.logging Common Logging implementation
org.eclipse.emf.common.jar org.eclipse.emf.common Common Base Event's Eclipse Modeling Framework (EMF) dependency
org.eclipse.emf.ecore.jar org.eclipse.emf.ecore Common Base Event's Eclipse Modeling Framework (EMF) dependency
hexr.jar org.eclipse.hyades.execution TPTP Logging Agent dependency
hl14.jar org.eclipse.hyades.logging.core TPTP support for JSR-047 logging APIs
hlcbe101.jar org.eclipse.hyades.logging.core Common Base Event implementation
hlcore.jar org.eclipse.hyades.logging.core Common Base Event's TPTP Logging Core dependency
org.eclipse.core.runtime.jar org.eclipse.core.runtime Eclipse Logging implementation

Running the sample

To run this sample, follow these steps:

  1. If the workbench's default JRE is not version 1.4.0 or above, modify the newly created Java project (CommonLoggingProject) to compile and execute using JRE 1.4.0 or above by doing the following steps:
    1. Select the CommonLoggingProject, right-click and select Properties.
    2. In the properties dialog, select Java Build Path.
    3. Under the Libraries tab, select JRE System Library and click on the Remove button.
    4. To add the new JRE, click the Add Library button.
    5. In the Add Library dialog, select the JRE System Library from the list and click Next.
    6. Select the Alternate JRE option, and click Installed JREs to add a JRE. The preferences dialog for Installed JREs opens.
    7. Click Add.
    8. On the Add JRE dialog, specify the name and home directory of the JRE 1.4.0. Click OK.
    9. Click OK.
    10. Click Finish.
    11. Click OK in the properties dialog.
  2. Confirm that all compilation errors have been fixed.
  3. Add the required plug-ins (listed above) to the Workbench's search path.
  4. Create a run-time instance of the Workbench:
    1. Open the preferences dialog by selecting Window > Preferences.
    2. Select Plug-in Development > Target Platform.
    3. Click on the Reload button.
    4. Click OK.
    5. Select Run > Run As > Eclipse Application. A new instance of the Workbench will launch. Use the new instance to run the next step.
  5. Run the Common Logging sample by selecting Common Logging Sample > Run from the main menu.