Skip to content

LogLevels

Juan Antonio Castillo edited this page Feb 27, 2022 · 2 revisions

What is Log Severity Level

In jachLog, each log entry have an associated severity level.

To start, it indicates and kind of message it contains. The jachLog severity levels are based on the Severity of the SysLog entries. SysLog is a industry standard for message logging.

The severity levels are: Emergency, Alert, Critical, Error, Warning, Notice, Informational, Debug.

For more information on this values, read about the standard/recommended meaning of severity level values.

How to filter out log entries based on its level

The second problem you face regarding to application logging, is the amount of log that a complex, mature and running application generates. (The first if having an application that generates no log at all).

To help you provide ways to your customers/users to deal with this problem at the origin, the class allows you to fine tune which messages are written to the destinations and which messages are just ignored at any runtime moment. You can provide means to your users to change the level of filtering of your application by just adjusting the LogLevel property for the different topics of log (or for the default topic if your application is simple and doesn't use topics).

If your application just needs to write all the log entries to destinations, pass the llAll or llDebug values to the constructor of the logger object and you can just ignore all this stuff.

The LogLevel property acts as a threshold of which messages are written to the destinations. For example

  • if you set the property to llNotice, only entries with Notice or above severity level will be written to the destinations: Emergency, Alert, Critical, Error, Warning and Notice. Below that level (Informational and Debug) all generated messages are filtered off, which means they are ignored and never written to any destination.
  • if you set the property to llCritical, only entries with Critical or above severity level will be written to the destinations: Emergency, Alert and Critical. Below that level (Error, Warning, Notice, Informational and Debug) all generated messages are filtered off, which means they are ignored and never written to any destination.
  • if you set the property to llDebug, all entries will be written to the destinations, since Debug is the last severity level. No messages are filtered out (except if you use DebugVerbosity).

You can set the LogLevel to the special values llOff, which means no messages will be written or llAll, which writes all messages, like llDebug.

Note that the LogLevel property is of type TLogLevel, while the log entries severity is of type TLogSeverity. There's an obvoius correspondence between both types, but the types remain different and are not interchangeable. The TLogLevel values are prefixed with ll while TLogSeverity values are prefixed with ls for that matter.