Adding trace points to an application

To include trace points in your application, complete the following steps:
  1. Define a final public static variable to hold each component identifier you want to work with. For example, in the class MyClass, include the following:
    public static final String COMPID = "APPL1";
    Note: Component identifiers are limited to 6 characters. Do not use the number-sign character ( # ) in the first position, as this is reserved for use by the toolkit.
  2. Include an entry in the keyed collection trace.requesterComponents of the configuration file for each component to be traced. Specify the types and levels to be enabled for each component, as in the following example:
    <traceRequester id=""APPL1"" trace="yes" traceTypes="DWS" traceLevels="HL" /> 

    For guidance, see Recommended combinations of types and levels.

  3. Code a query of the Trace Facility at the trace point to determine if the level and type are enabled for the code's component. This is very important, in order to minimize the creation of unnecessary objects and the resulting negative impact on performance.
  4. If the previous step returns true, build the trace record and invoke the Trace Facility.
Example (for steps 3 and 4):
If (Trace.doTrace (MyClass.COMPID,Trace.Medium,Trace.Debug)) {

	String aMessage, aTID
	aMessage = ...;
	aTID = ...;
	Trace.trace 
  		(MyClass.COMPID,Trace.Medium,Trace.Debug,aTID,aMessage);

}
Note: aMessage and aTID are only created if the component is registered for the level "Medium" and the type "Debug".
Related reference
Recommended combinations of types and levels