Show TOC Start of Content Area

Background documentation Types and Contents of Trace Messages  Locate the document in its SAP Library structure

Trace Message Types

Trace messages are used for understanding the program execution path and the internal status of the application.Tthe referenced methods belong to class com.sap.tc.logging.Location.

Two principal types of trace messages can be distinguished:

      Program flow trace messages

Information about which part (subroutine/method) of the program is executed and what control action is needed. If the program flow leaves one component and enters another one (with other responsible development groups), trace messages must be issued to help support engineers in localization of the right responsible one.

Messages of this type must use the severity level PATH. The SAP Logging API provides helper methods like entering(), exiting(), throwing() and catching().

      Program context trace messages

”Program context” can be:

       Information about the semantically execution step and its results.

Messages of this type must use the severity level INFO.

       Status of important variables. This has to be used with care to avoid replacing debugging. These are mostly variables holding a status description.

Messages of this type must use the severity level DEBUG.

       Important return codes of calls. For example, access to external resources, resource bundles, processing engines and libraries. Depending on the evaluation of the return code the severity level can be DEBUG or INFO.

       Results of condition checks. If there are critical conditions that need to be satisfied in specific places of the code, a trace message must be issued. This is used to check for non-repairable inconsistencies in the program status.

The severity level of such kind of messages must be ERROR. The SAP Logging API provides the helper method assertion().

       Technical information in application termination conditions. As part of the error handling, an exception is created. A notification on this event has to be written as a log entry. If you need to write additional technical context information, it must be written as a trace with severity ERROR immediately before the throw statement (or inside a catch block).

Content of Trace Messages

As a general rule, the trace has to contain a detailed identification of the executed code. Depending on the type of trace message, the following information must be provided:

      Program flow trace messages

The name of the current execution unit and the type of activity (entrance or leave of an execution unit) must be provided. In case of abnormal leaves or entrances of an execution unit, details to the situation need to be provided.

      Program context trace messages

In general, the information provided in these messages must help to quickly and briefly understand the program context. This can be the name and value of important variables.

If a variable holds a complex object, it is recommended not to insert a complete textual description of the object, since this will flood the trace file with probably useless information. A better idea is to include a brief description of the object, for example the object ID or name and a selection of most important attributes. A detailed examination has to be performed via debugging.

 

End of Content Area