During the development phase, it is common practice to insert logging statement within the code to produce informative logs at runtime, whether for troubleshooting or for analysis purposes.
Without a standard logging framework, developers are likely to use System.out.println in a sporadic manner or to call printStackTrace() in the case of an exception.
Before executing the code in a productive system, the cleanup of these embedded lines can be very difficult. Therefore, this is not a flexible method to control the amount of log output, the destination, and the message format.
In the SAP Logging API, the messages are separated in two main areas:
● Logging – classical log messages, for distinguished problematic areas.
● Tracing – classical trace messages, for coding problems.
The availability and readability of logs or traces are very important for both developers and administrators. Therefore, a common logging framework must be made available to satisfy the requirements of these groups.
This framework has the following advantages:
● Easy to use API - enabling logs is not a popular task for a developer. Therefore, the API/method calls have to be simple and intuitive.
● Performance - switching on the logging mechanism must not degrade the performance of the application as if running with logging.
● Easy to maintain - the log insertion done by developer is totally decoupled from executing the code.
Switching on or controlling the amount of log output is configurable at runtime without modifying the source code.
If you want to define distinguished problematic logistic areas, you should focus on log messages. While, if you are interested in analyzing code problems, then trace messages are relevant.
Enabling logging is a major task. What you have to do is classify the source area to be logged/traced, and then insert the output messages in the code.
The figure below represents a simplified version of the conceptual view that shows the key entities in the SAP Logging API.
The terms used are described in the Key Components table after the figure.
Conceptual View of SAP Logging Tool
Terminology of Key Components
Term |
Description |
Logging Manager |
A module that manages the process of logging system events. The Log Manager is part of the Java Enterprise Runtime and is the first manager to be started at system startup. |
Log Controller |
A Java object that manage the writing of log/trace messages. |
Log Record |
A structure that holds a message and its relevant data. |
Log |
Represents the destination where the message should be output. |
Formatter |
Determines the format of the final message text. |
Filter |
Optional means to further screen out messages. |
The SAP logging API provides the following functionality:
...
● Using of both tracing and logging
● Making use of similarities between tracing and logging
● Cross-referencing between traces and logs
● Language-independency for log messages
● Working with different output formats and destinations
● Controlled inheriting of code areas and message categories
See also:
Enabling Logging for an Application