Logging Quick Guide
This Quick Guide gives an overview of:
● general rules for using the logging infrastructure
● preparation steps
● usage of logging and tracing
● configuration steps
● performance remarks
● 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 but in areas according to his/her administration tasks.
● A developer, however, wants to see the details of the software 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 J2EE 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.
Categories emit the log records. There are three top categories: System, Applications and Performance.
● /System – 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 – contains all messages related to the business logic belong.
● /Performance – 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 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)”;
● The default severity setting for categories has to be INFO (so all log messages with severity INFO or higher will be written)
● The default severity setting for locations has to be ERROR.
Therefore, if you have exceptions, which you always want to trace, use the traceThrowableT method of the Location class.
● You can manually edit the log configuration XML file of your category or location and deploy it with libraries, interfaces, or applications. To deploy a logging configuration together with your component, you have to include the XML file into its corresponding archive. The name of the XML file must be "log-configuration.xml". It must follow a particular syntax.
For more information, see log-configuration.dtd.

If the log-configuration.xml file is to be deployed with an application, it must be placed in the META-INF directory of the application's archive.
If it is to be deployed with a library or interface, it must be placed in the subdirectory called "dispatcher(or server)/descriptors". Whether the XML file will be in the "dispatcher/descriptors" only, or in the "server/descriptors" only, or in both directories, it depends on the cluster node the component is deployed to.
● You can use the SAP NetWeaver Developer Studio to add a log-configuration.xml file to your project and configure it during development.
For more information, see Log Configuration with SAP Netweaver Developer Studio.
● You can modify your logging configuration at runtime using the Visual Administrator.
For more information, see
Logging Configuration
Using the Visual Administrator.
Performance remarks
● If you have parameters, never build Strings yourself, always use the {n}-replacement
● If you have to make calculations for traces, check first if the tracing is active.
Then use the following: LOCATION.beLogged(severity)