Show TOC Start of Content Area

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

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

       1.      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 and have the output of those messages to attachable logs controlled uisng 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 to specify the 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.

Example

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 (by adding yet another suffix to the name).

       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'.

       A common naming practice for a location is to name it with the full path of the Java package name. Of course, you can randomly name a location with testLocation1_class1 for the class com.sap.fooPackage.Class1, but the output will not be very meaningful.

       2.      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. Log messages emitted to categories are classical log messages.

       The class Category is a subclass of LogController, so you can use corresponding calls to emit log messages, and have the output of those messages to attachable logs controlled via 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 to specify message severities.

       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 simply 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'. Do not forget to always start with '/'.

The actual writing of messages using a log controller is controlled via its severity setting specified with: <Controller>.setEffectiveSeverity(<Value>). For more information, see Assign Severity to a Source.

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>);

Or, instead of passing the name manually, for location, you can as well 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, while using the string argument (java.lang.String), you have the flexibility in the definition. For example, to include also the method name that explicitly controls logging over methods individually.

Once you have a handle to the source, you are ready to configure this source to generate messages. It is recommended that you assign the handle to be static in order to improve the efficiency:

This graphic is explained in the accompanying text

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

 

See also:

Relations Between Category and Location

 

 

End of Content Area