Show TOC

Background documentationCoding Recommendations Locate this document in the navigation structure

 

The development concept is simple – you need to add 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>). Respectively, for category object – Category.getCategory(<id>).

However, frequently making such a call may reduce performance.

Recommendation Recommendation

Note that, these output methods are outdated but not deprecated. You can use them at will. We recommend that you use the new class com.sap.tc.logging.SimpleLogger.

More information: SimpleLogger Class

End of the recommendation.
Hierarchical Naming Convention
  • We recommend that you create a static variable for the trace object.

    Also, it is a good practice 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 takes full advantage of the inheritance feature implemented by the SAP logging framework.

Example Example

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

End of the example.
  • Severity inheritance – If you set a certain severity level to the parent, that severity is not effective for its children.

    In order the parent and children to have the same severity, you should copy the parent severity to the children manually, using the SAP NetWeaver Administrator.

    More information: Configuring Log Controllers .

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

To avoid problems affecting the inheritance features, use the another API for Location.getLocation(<java_class>), which accepts a class other than a string.