## Working with the Hyades JSR-047 Logging Sample

Introduction
This sample demonstrates the Hyades support for logging Common Base Events (CBEs) using JSR-047 logging APIs implemented in JDK 1.4.0 or above (i.e. java.util.logging). Users experience logging CBEs 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 CBEs 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 Hyades' 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 following JAR files are required to compile and execute this sample:

JAR file | Plug-in it is contained in
hexr.jar | org.eclipse.hyades.execution.remote
hl14.jar | org.eclipse.hyades.logging.java14
hlcore.jar | org.eclipse.hyades.logging.core
hlevents.jar | org.eclipse.hyades.logging.core

Execution Steps
To run this sample, 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 > [JRE 1.4.0 or above] > Finish > OK).
2. Confirm that all compilation errors have been fixed.
3. Enable logging in the Profiling and Logging preferences (Window > Preferences > Profiling and Logging > Enable logging > OK).
4. 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).
5. Start the Hyades Data Collection Engine application or service.
6. Run the sample class (Run > Run... > Java Application > New > 'HyadesLoggingJava14Project' > Arguments > VM arguments > '-Djava.util.logging.config.file=<workspace>/HyadesLoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties' > Run).
7. Attach to the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' logging agent in the Profiling and Logging Perspective (Profile > Attach > Java Process > org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample > Next > > Profiling project > Browse... > 'HyadesLoggingJava14Project' > OK > Finish).
8. Start monitoring the 'org.eclipse.hyades.logging.java.sample.HyadesLoggingJava14Sample' logging agent (Profile > Start Monitoring).
9. Open the Log View in the Profiling and Logging Perspective to view the logged CBE log records (Window > Show View > Other... > Profiling and Logging > Log View > OK).
10. Refresh Log View in the Profiling and Logging Perspective (Profile > Refresh Views).
11. Alternatively, launch the sample class through the Profiling and Logging Perspective (Profile > Launch > Java Process > Project > Browse... > 'HyadesLoggingJava14Project' > OK > Main class > Search... > 'HyadesLoggingJava14Sample' > OK > VM arguments > '-Djava.util.logging.config.file=<workspace>/HyadesLoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties' > Finish).
12. Open the Log View in the Profiling and Logging Perspective to view the logged CBE log records (Window > Show View > Other... > Profiling and Logging > Log View > OK).
13. Refresh Log View in the Profiling and Logging Perspective (Profile > Refresh Views).