Show TOC

Identify the Output: Location or CategoryLocate this document in the navigation structure

Use

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

    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.

    The locations are named according to the known hierarchical structure from the Java packages.

    Example

    You can, for example, write all messages from the monitoring classes into a single log. So, you can call the location 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. However, you can use illegal characters bracketing a component with single quotes. For example: com.sap.'great.technology' .

    Recommendation

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

  • Category - describes messages specific to distinguished problem areas. Category is used to emit log messages. Typical problem areas are: databases, networking, security auditing, and others.

    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.

    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.

    Example

    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 the parent. Therefore, it passes its settings and attached logs to both of the children.

    It is a good practice if you want, for example, 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. However, you can use illegal characters bracketing a component with single quotes, for example, /System/'Other Database' .

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

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.

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

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