Show TOC Start of Content Area

Function documentation How to Write Log and Trace Messages  Locate the document in its SAP Library structure

Use

This section helps you understand the requirements of writing the content of log and trace messages.

The message content must be carefully designed, according to the addressees and the message type chosen. The difference between the two types of messages is:

      Log messages permanently record the events and status of a software system. Logs intended for a broader audience with different skills and backgrounds.

      Trace messages analyze a software system in detail from a programmers standpoint as exceptional procedure. Traces are intended for persons with development skills and deep understanding of the application.

For more information, see Logging and Tracing.

Prerequisites

You need to have basic knowledge of the SAP Logging API.

You also need to know the basic difference between categories and locations.

For more information, see SAP Logging API.

General Design Issues

      Structure of messages

As part of the application design phase, it is a good practice to list the available messages or, if possible, design a common pattern for the message layout, to keep them as uniform as possible.

More information: Types and Content of Log Messages

                                    Types and Content of Trace Messages

Recommendation

Since messages need to be translatable, it is a good practice to avoid abbreviations, complex sentences or messages that consist of multiple parts.

      Target groups and delivery channels

In general, there are multiple delivery channels for messages. Therefore, a message can be stored in a log or it can be delivered directly to the user interface informing the application user.

Caution

Technical infrastructure-related information must not be delivered to the user interface, since mostly the user cannot handle the problem.     

Example

The following Java exception was logged with severity FATAL in the log. Unfortunately, the problem is harmless and must be an INFO level message in the next version of the application.

In addition to the incorrect severity, the information about the “troublemaker” (that is, which resource cannot be found) is missing:

May 2, 2006 9:40:15 AM # Client_Thread_26     Fatal       java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key false in com.sapportals.portal.pcdeditor.iview.PCDEditorIViewPropBoxParams.createPropBoxParams

java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key false

      at java.util.ResourceBundle.getObject(Unknown Source)

      [..approx. 50 more lines of stacktrace..]

 

The improved message text should be:

Cannot find resource <resource> in bundle <bundle> while processing <brief application description>. Only the technical ID of the resource will be displayed.

Note

Also, this message must not be a log, but a trace message instead.

End of Content Area