Show TOC Start of Content Area

Background documentation Alternative for User-Defined Severities  Locate the document in its SAP Library structure

This logging framework provides several severity levels to control the logging output. Usually three or four of the severity levels are used. The others are used as additional severity levels for special logging behavior, mainly for distinguishing different applications/stages (for example, application area X, Y; initialization stage, and so on).

Common Requirement

Defining your own severity levels is a simple solution – that is, creating a distinguished severity level to control the logging output for a specific stage/area independently. For example, during the initialization stage, to output messages with a severity level between Severity.WARNING and Severity.ERROR. Therefore a customized severity level is desired, such as SEVERITY_INIT, which is stricter than WARNING and lower than ERROR.

However, there are few drawbacks with this approach:

      The definition of the customized severity levels is unclear to the users.

      It is difficult for developers to maintain and coordinate the customized severity levels among components and applications.

      The order of severity levels is always general.

The Solution Provided by the SAP Logging API

The SAP Logging API gives you the flexibility to adjust the severity level independently for different focuses (logging or tracing) using a relative severity. For example, more trace messages at the initialization stage. This can be achieved easily using the following code line, with category “initialization”:

loc.setEffecitiveSeverity(initialization, Severity.WARNING);

Then, when writing message, call the following with respect to this relative “initialization”:

loc.errorT(initialization, <….message….>);

Assuming logging is not turned on for other (with default Severity.NONE) trace messages with severity WARNING or above, the messages regarding the “initialization” will still be written to the corresponding destination logs.

 

 

End of Content Area