Using Trace Objects
You use trace objects to access log and trace mechanisms.

uml_tracelib.wmfcontains the class diagram in UML format. Open Word and import uml_tracelib.wmf as a graphic.
All trace
objects read their configuration information from the Log Configurator. See
also:
Log Configurator
Service.
You can use the following methods for the trace object:
Methods for the Trace
Method Name |
SAP J2EE Logging |
SAP J2EE Tracing |
Audits |
Measure of Performance |
Comment |
Trace |
Yes |
Yes |
No |
Yes |
Constructor |
Entering |
No |
Yes |
No |
Yes |
First call in an instrumented method, in other words a method that has monitoring functions. |
Exiting |
No |
Yes |
No |
Yes |
Last call in an instrumented method if no exception occurs. |
Throwing |
No |
Yes |
No |
No |
Last call in an instrumented method if an exception occurs. |
Catching |
No |
Yes |
No |
No |
First statement in an instrumented catch block. |
debugT infoT warningT errorT fatalT assertion |
Yes |
Yes |
No |
No |
Used in J2EE logging if the category object is specified (is not Null). |
beLogged |
No |
Yes |
No |
No |
Checks tracing relevance |
Methods for Audit Monitoring
Method Name |
SAP J2EE Logging |
SAP J2EE Tracing |
Audits |
Measure of Performance |
Comment |
Audit |
No |
No |
Yes |
No |
Constructor |
addAuditLogEntry |
No |
No |
Yes |
No |
Use the AuditMessageKey |
flushAuditLogEntries |
No |
No |
Yes |
No |
Writes audits to the database. All audit log entries are collected in the memory before this method is called. |
All trace objects read their configuration from the J2EE Log Configurator service. The settings are updated once a minute. Therefore, the trace object will take at most one minute to react to any possible changes.
· If the trace object constructor is called, then the location for which the trace object writes traces and logs must be specified in the version parameter by the caller.
The version string must have the following format:
$Id:[additional string, for example, directory path]com/[package].java#[version number] $

$Id: //tc/dev/com/sap/aii/af/sample/ra/CCIConnectionFactory.java#1 $
The highlighted parts indicate the location of the SAP logging API for which you can set the logging level, for example.
· Note the following rules for code instrumentation:
¡ SAP J2EE Logging
§ Determine all information that might be interesting for a system administrator.
§ Set fatalT(), warningT(), and errorT() wherever an error can affect the system.
§ To document successful processing in the adapter, set infoT() (for example, adapter started, message processed successfully, and so on).
§ Only use debugT() very restrictively.
¡ SAP J2EE Tracing
Use entering(), exiting(), throwing() and catching() throughout the adapter code, particularly in the message processing area. The trace is used by SAP Support to determine the location and cause of the error.
¡ Audit Logs
You must write at least one audit log AuditLogStatus.SUCCESS or AuditLogStatus.ERROR in the adapter or the adapter services of the Adapter Framework for each message.