Working with the JSR-047 Logging sample
This sample demonstrates the TPTP 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.
If you have not already done so, create the example by File >
New > Example... >Logging > JSR-047 Logging Sample.
The contents of the sample Java source code should be obtained from CVS
and stored in org.eclipse.tptp.platform.examples_<version>.jar with a path of archive\HyadesLoggingJava14Sample. The plugin.xml contents of org.eclipse.tptp.platform.examples_<version>.jar should be updated to include the relevant extension and extension
points from plugin.xml revision 1.3 in CVS.
The 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) are included.
JRE 1.4.0 or above (i.e. java.util.logging) is required to compile and execute this sample.
.
Assumptions
- When launching
this application from the Profiling and Logging Perspective of the workbench, the
Agent Controller application or service, or Integrated Agent Controller, is configured to use JRE 1.4.0 or
above.
- The 'java.util.logging.config.file' environment variable is set to the JSR-047 logging (that is, java.util.logging) configuration file's (HyadesLoggingJava14Sample.properties) absolute path and name. For example, <workspace>/LoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties.
Launching
To run this sample and automatically attach to the Logging Agent, follow these steps:
- If the workbench's default JRE is not 1.4.0 or above, modify the newly created Java project (i.e. LoggingJava14Project) 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).
- Confirm that all compilation errors have been fixed.
- If you are using a standalone installation of the Agent Controller(AC), then make sure it is started (not required). Alternatively you can use Integrated Agent Controller which is included with the workbench.
- Open the Profiling and Logging Perspective (Window > Open Perspective > Other... > Profiling and Logging).
-
Run the sample class from the Profiling and Logging Perspective (Run > Profile... > Create a new launch configuration of type
Java Application > Set the project name to the example's project name > Set the Main class to 'HyadesLoggingJava14Sample' >
Switch to the arguments tab and set the following JVM property:
-Djava.util.logging.config.file="<workspace>/HyadesLoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties"
>Switch to the Monitor tab > De-select "Java Profiling" and select "Agent Discoverer" > Profile).
- After a few seconds, the logging agent should automatically be detected and attached. Select the logging agent discovered and 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).
- Refresh Log View in the Profiling and Logging Perspective (right-click the 'HyadesLoggingJava14Sample' Logging Agent > Refresh).
- Two Log records should display in the Log view.
Alternatively, to run this sample and manually attach to the Logging Agent, follow these steps:
- If the workbench's default JRE is not 1.4.0 or above, modify the newly created Java project (i.e. LoggingJava14Project) 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).
- Confirm that all compilation errors have been fixed.
- If you are using a standalone installation of the Agent Controller(AC), then make sure it is started (not required). Alternatively you can use Integrated Agent Controller which is included with the workbench.
-
Run the sample class from the Java Perspective (Run > Run... > Create a new launch configuration of type Java Application >
Main class > Search... > HyadesLoggingJava14Sample > OK > Switch to the arguments tab and set the following JVM property:
-Djava.util.logging.config.file="<workspace>/HyadesLoggingJava14Project/cfg/HyadesLoggingJava14Sample.properties"
>Run).
- Open the Profiling and Logging Perspective (Window > Open Perspective > Other... > Profiling and Logging).
- Attach to the 'HyadesLoggingJava14Sample' Logging Agent in the Profiling and Logging Perspective (Run > Profile... > Attach - Java Process > New > Hosts tab > Use 'localhost:<port>' if you are not using a standalone installation of the Agent Controller. Use a valid hostname and a port otherwise. > Agents tab > Double click the HyadesLoggingJava14Sample agent > Select the Destination tab > Profiling project > Browse... > 'HyadesLoggingJava14Sample' > OK > Profile).
- Start monitoring the 'HyadesLoggingJava14Sample' Logging Agent (<right-click the 'HyadesLoggingJava14Sample' Logging Agent> > Start Monitoring).
- 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).
- Refresh Log View in the Profiling and Logging Perspective (<right-click the 'HyadesLoggingJava14Sample' Logging Agent> > Refresh).
- Two Log records should display in the Log view.
(C) Copyright IBM Corporation 2000, 2007.