Show TOC

Background documentationHow to Write Log and Trace Messages Locate this document in the navigation structure

 

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

The content of a message 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 much 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.

More information: Logging and Tracing.

Prerequisites

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

More information: 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 Recommendation

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

    End of the recommendation.
  • 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 Caution

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

    End of the caution.

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, 2007 9:49:16 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.

Caution Caution

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

End of the caution.