Identify the Output: Location or Category

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.

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

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

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