## Working with the Hyades JSR-047 Logging Sample

Introduction
This sample demonstrates the Hyades support for logging Common Base Events using JSR-047 logging APIs implemented in JDK 1.4.0 or above (i.e. java.util.logging). Users experience logging Common Base Events to the console and a Logging Agent. The Logging Agent may be monitored via the Hyades Data Collection Engine application or service and the Hyades workbench.
Contents
The contents of the sample include the Java source code, dependencies (excluding java.util.logging classes) and configuration file necessary to log Common Base Events to a JSR-047 logger implemented in JDK 1.4.0 or above (i.e. java.util.logging).
Requirements
JRE 1.4.0 or above (i.e. java.util.logging) is required to compile and execute this sample.
Assumptions

1. When either launching this application from the Profiling and Logging Perspective of the workbench or attaching to a Logging Agent using the workbench, the Hyades Data Collection Engine application or service is configured and running.
2. When launching this application from the Profiling and Logging Perspective of the workbench, the Hyades Data Collection Engine application or service is configured to use JRE 1.4.0 or above.
3. <workspace> represents the absolute path to the workbench's workspace.
4. The 'java.util.logging.config.file' environment variable is set to the JSR-047 logging's (i.e. java.util.logging) configuration file's (HyadesLoggingJava14Sample.properties) absolute path and name. For example, <workspace>/HyadesLoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties.

Dependencies
The JAR files that are listed in the table are required to execute this sample:

JAR file | Plug-in it is contained in | Reason for requirement
hexr.jar | org.eclipse.hyades.execution.remote | Hyades Logging Agent
hlcore.jar | org.eclipse.hyades.logging.core | Common Base Event's Hyades Logging Core dependency
hlcbe101.jar | org.eclipse.hyades.logging.core | Common Base Event implementation
hl14.jar | org.eclipse.hyades.logging.java14 | Hyades support for JSR-047 logging APIs
ecore.jar | org.eclipse.emf.ecore | Common Base Event's Eclipse Modeling Framework (EMF) dependency
common.jar | org.eclipse.emf.common | Common Base Event's Eclipse Modeling Framework (EMF) dependency

Execution Steps
To run this sample and manually attach to the Logging Agent, follow these steps:

1. If the workbench's default JRE is not 1.4.0 or above, modify the newly created Java project (i.e. HyadesLoggingJava14Project) to compile and execute using JRE 1.4.0 or above (Project > Properties > Java Build Path > Libraries > JRE_LIB > Remove > Add Library... > JRE System Library > Next > Alternate JRE > Installed JREs... > Add... > JRE home directory > Browse... > [JRE 1.4.0 or above] > OK > OK > OK > Finish > OK).
2. Confirm that all compilation errors have been fixed.
3. Start the Hyades Data Collection Engine application or service.
4. Enable logging in the Profiling and Logging preferences (Window > Preferences... > Profiling and Logging > Enable logging > OK).
5. Run the sample class from the Java Perspective (Run > Run... > Java Application > New... > Main class > Search... > org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample > OK > Arguments > VM arguments > '-Djava.util.logging.config.file=<workspace>/HyadesLoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties' > Run), where <workspace> represents the absolute path to the workbench's workspace.
6. Open the Profiling and Logging Perspective (Window > Open Perspective > Other... > Profiling and Logging).
7. Attach to the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' Logging Agent in the Profiling and Logging Perspective (Run > Profile... > Attach - Java Process > New > Agents > org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample > Profiling > Destination > Profiling project > Browse... > 'HyadesLoggingCommonsProject' > OK > Run).
8. Start monitoring the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' Logging Agent (<right-click the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' Logging Agent> > Start Monitoring).
9. Open the Log View in the Profiling and Logging Perspective to view the logged Common Base Event log records (Window > Show View > Other... > Profiling and Logging > Log View > OK).
10. Refresh Log View in the Profiling and Logging Perspective (<right-click the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' Logging Agent> > Refresh).

Alternatively, to run this sample and automatically attach to the Logging Agent, follow these steps:

1. If the workbench's default JRE is not 1.4.0 or above, modify the newly created Java project (i.e. HyadesLoggingJava14Project) to compile and execute using JRE 1.4.0 or above (Project > Properties > Java Build Path > Libraries > JRE_LIB > Remove > Add Library... > JRE System Library > Next > Alternate JRE > Installed JREs... > Add... > JRE home directory > Browse... > [JRE 1.4.0 or above] > OK > OK > OK > Finish > OK).
2. Confirm that all compilation errors have been fixed.
3. Start the Hyades Data Collection Engine application or service.
4. Enable logging in the Profiling and Logging preferences (Window > Preferences... > Profiling and Logging > Enable logging > OK).
5. Add the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' Logging Agent to the Profiling and Logging preferences (Window > Preferences... > Profiling and Logging > Logging Agents > New agent > org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample > Add agent > OK).
6. Open the Profiling and Logging Perspective (Window > Open Perspective > Other... > Profiling and Logging).
7. Run the sample class from the Profiling and Logging Perspective (Run > Profile... > Java Application > New... > Main class > Search... > org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample > OK > Arguments > VM arguments > '-Djava.util.logging.config.file=<workspace>/HyadesLoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties' > Run), where <workspace> represents the absolute path to the workbench's workspace.
8. Open the Log View in the Profiling and Logging Perspective to view the logged Common Base Event log records (Window > Show View > Other... > Profiling and Logging > Log View > OK).
9. Refresh Log View in the Profiling and Logging Perspective (<right-click the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' Logging Agent> > Refresh).