Only log temporary errors by default - SchwarzIT/sap-usi-logging-api Wiki

Some errors occur permanently, others are temporary.

It would be bad to always log everything without considering the "nature" of an error, as this would flood the application log with useless messages. Writing so many log messages could have a negative impact on the overall performance of the database and would waste a lot of disk space.

Logging nothing is almost as bad as the previous option, as developers could spend hours looking for "errors" that occurred temporarily because, for example, a remote system was rebooted and therefore could not be reached.

The ideal solution would be a good compromise between the two options, so the recommendation is to log only temporary errors by default.

How to achieve that

The logging API uses log levels to control the detail level of the log (see: Customizing -> Log Levels -> Product specific Log Level).

For each log message, a so-called problem class must be provided. The problem class indicates the severity of the message. A message passed to the log writer will only be logged if the severity of the message is high enough.

In order to log only temporary errors by default, at least one problem class must be reserved exclusively for temporary errors. Since the default problem class assumed by the log writer methods is ' ' (Other), the priority of the reserved problem class has to be higher than that.

The recommendation is to reserve problem class '1' (very important) for temporary errors.

Setting the product specific log level to 1 as well will ensure, that only very important messages are logged by default.