Show TOC Start of Content Area

Background documentation Identify the Output Source: Location or Category  Locate the document in its SAP Library structure

Use of Log Controllers

The messages in the logging system are emitted via the LogController Java class. There are two kinds of log controllers:

      Location – describes messages that originate from delimited source code areas. Above all, the location is used to emit trace messages. Typical source code areas are components, packages, classes, and methods.

The class Location is a subclass of LogController. Therefore, with the corresponding calls you can emit trace messages, using the severities of the locations and optional filters assigned to them.

This graphic is explained in the accompanying text

Use the constants provided by the class Severity.java to specify the trace message severities.

The locations are named according to the known hierarchical structure from the Java packages. If you want to write all messages from the monitoring classes into a single log, you can call the location named com.sap.tc.monitoring. You can then collect all messages from the technology components in a common log, simply by assigning that log to the parent location com.sap.tc. The log is then passed to all child locations (in particular to com.sap.tc.monitoring.)

In addition, it is possible to include method signatures in the location names. For example, com.sap.tc.monitoring.Node.announce(java.lang.Object) is the location of a method named announce that has an argument of the class Object. This way, you can distinguish the overloaded methods and even the local classes.

The hierarchical components must be compliant with the Java identifier syntax, but you can use illegal characters bracketing a component with single quotes, for example, com.sap.'great.technology'.

Note

A common naming practice for a location is to name it with the full path of the Java package name.

      Category – describes messages specific to distinguished problem areas. Above all, it is used to emit log messages. Typical problem areas are: databases, networking, security auditing, and others. Messages emitted to categories are known as classical log messages.

The class Category is a subclass of LogController, so you can use corresponding calls to emit log messages, using the severities of the categories and optional filters assigned to them.

This graphic is explained in the accompanying text

Use the constants provided by the class Severity.java to specify the log message severities too.

The categories are named according to the known hierarchical structure from the file systems.

You can, for example, group together all categories of log messages concerned with system issues (database or networking problems), and name them /System/Database and /System/Network, respectively. The category /System is then the parent of the former two, and therefore passes its settings and attached logs to both of them.

This is useful, for example, if you want to have all system messages written to the same log. You do not have to attach the log to both the database and networking categories, but only to the common parent.

The hierarchical components of the name must be compliant with the Java identifier syntax, but you can use illegal characters bracketing a component with single quotes, for example, /System/'Other Database'.

Note

Do not forget to always start with '/'.

Various Access APIs

A static method is provided for each class for easy access to a location or category:

Location.getLocation(<name of the Location>);

Category.getCategory(<name of the Category>);

Note

Instead of passing the name manually, for location, you may pass the class instance (java.lang.Object) or the class itself (java.lang.Class). In this case, the location object refers by default to the class level.

Using the string argument (java.lang.String), you have the flexibility, for example, to include also the method name that controls logging over methods individually.

Once you have a handle to the source, you are ready to configure this source to generate messages.

Recommendation

It is recommended that you assign the handle to be static to improve the efficiency:

This graphic is explained in the accompanying text

static final Location loc = Location.getLocation(MyClass.getClass())

 

More Information

Appendix A: Severity Levels

Relations Between Category and Location

 

 

End of Content Area