Show TOC Start of Content Area

Background documentation Coding Recommendations  Locate the document in its SAP Library structure

The development logic is simple – you need to add just a few extra code lines, so that you can get the result in a log file.

Static Reference

The variable that holds the location object is declared with a static modifier to improve efficient access. Basically, a handle to a location object can always be obtained by calling Location.getLocation(<id>). However, making such a call every single time may reduce performance.

Hierarchical Naming Convention

It is recommended to create a static variable for the trace object. Also, it is a useful and easy approach to name the location object as the complete package path of the class. Thus, you establish both clarity and inheritance features available in the SAP Logging API.

When naming a location object for your Java class, it is a good practice if you use a hierarchical naming convention, such as the fully qualified name. This not only avoids ambiguity on classes having the same name, but also takes full advantage of the inheritance feature implemented by the logging framework.

Example

The class com.sapmarkets.foois parent to classes com.sapmarkets.foo.classA and com.sapmarkets.foo.classB, and the latter two classes are siblings.

      If you set a certain severity level to the parent com.sapmarkets.foo, that severity is not effective for its children – com.sapmarkets.foo.classA and  com.sapmarkets.foo.classB.

      If you want the parent and children to have the same severity level, you should copy the parent severity to the children manually using the SAP NetWeaver Administrator.

More information: Configuring Log Controllers .

      Logs in the parent controller are relevant to the children. Siblings do not affect each other.

To avoid problems that will affect the inheritance features, there is another API for Location.getLocation(<java class>), which accepts a class other than a string.

 

End of Content Area