Tracing and Logging in the SAP System

Objectives

After completing this lesson, you will be able to:
  • List the options available for tracing and logging in the SAP system
  • Perform simple traces in the SAP system

Traces and Logs

You can follow the process of various operations in your SAP system with trace functions. This allows you to monitor the system and isolate problems that occur.

Traces and Logs – Test and Definition

Trace

In the SAP context, a trace usually refers to an option for logging system processes that users can activate and deactivate. It may also be possible to configure their level of detail.

A good example: System trace, transaction ST01.

Log

In the SAP context, a log is typically a continuously recorded information flow that records certain events. These logs can be managed inside or outside the SAP system.

A good example: System log, transaction SM21.

System log is the analysis option for errors in the system and its environment.

There are functions that combine the properties of traces and logs, such as developer traces.

There are many trace options in SAP systems. The main ones are listed in Trace and Log Options.

Trace and Log Options

  • System log (SM21)

  • Dump analysis (ABAP runtime error: ST22)

  • System trace (ST01)

  • Performance analysis (ST05)

  • Error log files (developer trace: ST11)

Trace and Log Commands

You can use transaction SM21 to determine and correct errors that occur in your system and its environment. SAP application servers record events and problems in system logs. Every SAP application server has a local log that contains the messages, such as errors, warnings, and information, logged by this server.

If unpredictable errors occur at runtime when you call an ABAP program, a runtime error that generates a short dump is logged (transaction ST22).

If you want to record the internal SAP system activities, such as authorization checks, database accesses, kernel functions, and RFC calls, use the System Trace function (transaction ST01).

You can use the Performance Trace function (transaction ST05) to record database calls, lock management calls, and remote calls of reports and transactions in a trace file, and display the logged measurement results as lists. The Performance Trace also offers extensive support for a detailed analysis of individual trace records. You can find all the functions of the Performance Trace in the System Trace as well. The Performance Trace is a more suitable analysis tool for certain problems, since the reduced scope of functions makes it is easier to handle.

Technical information about internal SAP problems is logged in the developer traces (transaction ST11).

System Log (SM21)

Events and problems are recorded locally on each application server and can be displayed in the system log (syslog) in the SAP system, as shown in the following figure.

Note

In the context of the system log, see also the following SAP Notes:

  • SAP Note 712706: Program RSLGVIEW - reading the SAP system log without system
  • SAP Note 28665: Central syslog under NT.

    This SAP Note provides a solution that uses CCMS monitoring functions as well as a feature for viewing the logs for all instances of a system.

You can also use the SAP Microsoft Management Console and the SAP Management Console to view the system log, even if the instances in question were not started or were started and failed.

You display a system log with transaction SM21. By default, the system reads the log for the last one to two hours. As well as the local system log, you can display system logs for other application servers. On the initial Display the system log screen, you can specify for which instances the syslog should be displayed. The syslog messages will then be displayed for all selected instances.

You can define the path and file names for local log files with the following system profile parameters:

rslg/local/file: File name for the local log (standard: SLOG<SAPSYSTEMNUMBER>)

By default, the log files for the local system log are stored in the following directory: /usr/sap/<SID>/<instance_directory>/log.

The log file has a maximum size that can be configured with profile parameter rslg/max_diskspace/local. The oldest entries will be overwritten as soon as the limit is reached.

Hint

The system does not display a message when an old log file is overwritten.

Dump Analysis (ST22)

ABAP programs are checked statically when they are created and dynamically when they are running. Errors that are not statically predictable and only occur at runtime are identified dynamically by the ABAP runtime environment. States of this type lead to exceptions. If an exception is not handled or cannot be handled, a runtime error occurs. When a runtime error occurs, the ABAP runtime environment terminates the execution of the program, generates a so called short dump, and branches to a special screen for analyzing the short dump. You can access short dumps using transaction ST22.

A short dump is divided into different sections that document the error. The overview shows what other information is output in the short dump, such as contents of data objects, active calls, control structures, and so on. You can branch to the ABAP Debugger at the termination point from the short dump view. The following different error situations exist:

  • Internal error

    The kernel identifies an error state. In this case, send a message to notify SAP.

  • Installation and environment/resource error

    In this case, an error occurred that was caused by incorrect system installation or missing resources (such as the database being shut down).

  • Error in application program

    Typical causes of errors are:

    • Content of a numerical field not in the correct format

    • Arithmetic overrun

    • An external procedure is not available

    • Type conflict when transferring parameters to an external procedure

By default, short dumps are stored in the system for 28 days. You can delete short dumps in accordance with a time specification using the reorganize function, which you can call by choosing GotoReorganize. You can save a short dump without a time limit using the keep function, which you can choose from the Detail View under Short DumpKeep/Release.

If problems that you cannot solve yourself occur with ABAP programs, you can send an extract of the short dump to SAP. A short dump is an important basis on which the SAP Hotline and remote consulting solve problems.

Important Features of Dump Analysis

  • If a runtime error occurs, a short dump is generated. You can use transaction ST22 to analyze the short dump.

  • Dump data is stored in the database.

  • Dump data can be reorganized.

  • Individual short dumps can be flagged for retention.

System Trace (ST01)

You can use the SAP system trace (system trace for short) to record internal system activities. You can call the system trace using transaction ST01. You can also use transaction ST01 to display the non-actively displayed trace file.

Hint

For system monitoring and problem analysis, we recommend that you use the system log or the developer trace.

The System Trace Is Used to Analyze the Following:

  • Authorization checks

  • Kernel functions

  • Kernel modules

  • DB accesses (SQL trace)

  • Accesses to table buffers

  • RFC calls, also RFC Trace

  • HTTP calls

  • Lock operations (client-side), also Enqueue Trace

You select the components to be logged on the initial screen. You can use the system trace for tracing authorization checks. If the trace is activated for the authorization check, all authorization checks performed by the system are recorded. During the evaluation, you can identify which authorizations the system checked at which times. The following detailed information is also provided: Date, time, work process number, user, authorization object, program, line, number of authorization values, and authorization values.

Hint

For tracing authorization checks exclusively, you can use transaction STAUTHTRACE.

You can use the SQL trace to follow how the Open SQL commands in reports and transactions are converted to standard SQL commands and the parameters with which the SQL commands are transferred to the database system in use. The results of the SQL command are also logged, such as the return code and the number of records found, inserted, or deleted by the database. Logging the execution time and the call point in the application program allows you to perform more advanced evaluations.

With the enqueue trace, you can follow which lock instructions the SAP system performs on which lock objects, and which parameters the system uses for these locks. The program that triggered the lock, the owner of the lock, and the time that the enqueue server required to release the lock again are all also logged in the trace file.

You can use the RFC trace to follow which remote calls the SAP system executes, and the instance on which these calls are executed. From the trace recording, you can see which function modules were called remotely by the program to be analyzed and whether the RFC call was successfully executed. The total time required for the execution of the remote call and the number of bytes sent and received during the RFC are also logged in the trace file.

Performance Trace (ST05)

The performance trace is used for analyzing the following:

  • Database calls (SQL Trace)

  • Lock management calls (Enqueue Trace)

  • Accesses to table buffers (Buffer Trace)

  • Remote calls of reports and transactions (RFC Trace)

  • HTTP communication (HTTP Trace)

  • Single SQL statements (Enter SQL Statement)

The performance trace provides similar trace options to the system trace. It allows you to record database calls, calls to lock management, calls to table buffers, and remote calls of reports and transactions from the SAP system itself in a trace file. You can call the performance trace using transaction ST05.

Hint

The functions of the performance trace are integrated into the ABAP Workbench and can therefore be called from there.

Developer Trace (ST11)

Developer traces are recordings that contain technical information and are used if errors occur. This type of process trace is especially useful to investigate host and internal SAP problems that are affecting your SAP system. Developer traces dev_ * are written to files in the directory/usr/sap/<SID>/<instance directory>/work of the SAP application server that generated the trace, as shown in the figure Developer Traces.

You can access the developer traces in the operating system, in transaction AL11, transaction ST11, or transaction SM50 (work process overview). In transaction SM50, you can switch to the individual dev_* traces by choosing ProcessTraceDisplay File. You can display additional details in the displayed traces by expanding individual entries.

Trace File Configuration

You can use system profile parameters to restrict the size of the trace files and to specify an appropriate path.

Hint

You are probably aware of several ways of displaying values for the parameter rstr*. Transaction ST01 provides a particularly effective option for this purpose. To do so, call transaction ST01 and choose the menu path GotoAdministration (Shift+F7). The following display lists all relevant parameters. Maintenance is also possible. Familiarize yourself with this function if you like and demonstrate it to the participants.

The SAP system trace writes the trace data in trace files. For performance reasons, this is not done directly, but instead using a process-internal buffer. The profile parameter rstr/buffer_size_kB determines the size of this buffer. The SAP trace stores data in multiple files, which are written sequentially. The parameter rstr/filename defines the base name of these files. There is always one file with exactly this name. If the file is full (parameter rstr/max_filesize_MB), the file is renamed and a new file is created with the base name. When the file is renamed, a number between 00 and 99 is added to the file name. The parameter rstr/max_files determines the maximum number of files. If this value is exceeded, the files are overwritten.

Optional: Troubleshoot a Problem in the System by Activating a Trace

Business Example

As an SAP system administrator in your organization, you want to troubleshoot problems in the SAP system using trace functions.

Note

In this exercise, when the values include ##, replace the characters by the number your instructor has assigned to you.

Task 1: Work with the Performance Trace

You want to test the performance of the database.

Steps

  1. Activate the SQL trace for your user in the Performance Trace (transaction ST05).

    1. In your SAP system, call transaction ST05.

    2. Select SQL Trace.

    3. Activate the trace by choosing Activate Trace.

  2. In a new GUI window, start transaction SE38 and execute the program RSUSR000 that displays the list of all logged users.

    1. On the top left choose the hamburger menu and select New GUI Window.

    2. Start transaction SE38.

    3. Enter program name RSUSR000.

    4. Choose Execute.

    Result

    The list of users logged on the application servers is displayed. The information is retrieved from the database.
  3. Go back to the Performance Trace, deactivate the trace and evaluate it.

    1. Go back to the GUI Window of your SQL Trace.

    2. In transaction ST05 choose Deactivate Trace.

    3. Choose Display Trace to evaluate the generated trace file.

    4. In Trace Types section, select SQL Trace.

    5. Choose Execute.

    6. Adjust the trace period if necessary.

    7. Select the line that contains the Object Name with the value USR02.

    8. Choose Goto → Display DDIC Information (F6) to display the SAP Dictionary information for this object.

    9. In the upper left use the Back (F3) icon < to go to the previous screen.

    10. Choose Exit in the upper right-hand corner.

    11. Choose Edit → Display Execution Plan > Selected Statement, Without Session Vars (F9) to display the execution plan for the SQL statement.

Log in to track your progress & complete quizzes