Logging Overview
Use
-
Bear in mind the difference between logs and traces. Logs are mainly addressed to an administrator of a customer system; traces - to a developer and support organization.
-
An administrator is not interested in the details of the software architecture and the SAP's organizational structure but in areas according to his/her administration tasks.
A developer, however, wants to see the details of the control flow. A log file can be a good starting point for error analysis done by support engineers.
-
Logs are written to Categories, and traces - to Locations. Categories corresponds to administration tasks and are shared between different applications. Locations refer to certain points in the coding and can be identified with package-, class-, or function names.
-
During normal operation, developers and support engineers are not looking on a running system. The administrator, however, has to check the system regularly. This implies that traces have not to be shown during normal operation, but logs do.
-
For performance reasons, in the current AS Java configuration no traces are written during normal operation, but logs of severity INFO and higher are.
-
Messages with severity DEBUG and PATH must be written as traces, not as log messages.
-
Any error message (with severity ERROR or FATAL) is recommended to be written as a log message.
-
Log files must have an extension .log , trace files - an extension .trc .
-
Use always the exception framework as a basis to define your own exceptions.
Features
Categories
Categories emit the log records. There are three top categories: System , Applications and Performance .
-
/System category - contains all system related log records belong. These logs are typically observed by a system administrator, who is not supposed to have any knowledge of the business processes.
-
/Applications category - contains all messages related to the business logic belong.
-
/Performance category - contains the Single Activity Trace.
Below the /System category, there are the following predefined subcategories:
/System/Database
/System/Network
/System/Server
/System/Security
/System/UserInterface
/System/Audit (only for audit-traces written by BaseException.trc )
For convenience and to avoid unnecessary object creation, the following static variables are defined:
-
com.sap.tc.logging.Category.SYS_DATABASE;
-
com.sap.tc.logging.Category.SYS_NETWORK;
-
com.sap.tc.logging.Category.SYS_SERVER;
-
com.sap.tc.logging.Category.SYS_SECURITY;
-
com.sap.tc.logging.Category.APPLICATIONS;
-
com.sap.tc.logging.Category.SYS_USER_INTERFACE;
Locations
Locations emits trace records. In every important class, create a reference to a Location, which corresponds to the fully qualified name of this class:
private static final Location LOCATION = location.getLocation(Locking.class);
Use a static String object to hold the name of the method.
String METHOD = "createLock(String)";
Configuration Considerations
-
The default severity setting for categories is WARNING.
Therefore, all log messages with severity WARNING or higher will be written.
-
The default severity setting for locations is ERROR.
Therefore, if you have exceptions that you always want to trace, use the traceThrowableT method of the Location class.
-
If you have parameters, never build strings yourself, always use the {n}-replacement.
-
If you have to make calculations for traces, use the following: LOCATION.beLogged(severity) .
-
You can modify your logging configuration at runtime, using the SAP NetWeaver Administrator.
More information: Log Configuration with the SAP NetWeaver Administrator .