Skip to content

Logging

You can enable server side logging in Kittox, which will allow you to see trace data useful for debugging or log your own data from your server side code (such as custom controllers or rules, for example). The logging system is pluggable and multiple loggers can be active at once.

Logging to file

In order to enable logging to file, you write something like this in your Config.yaml:

yaml
Log:
  # 1 = Minimal, 5 = Debug.
  Level: 5
  TextFile:
    FileName: %APP_PATH%log.txt
  # Set this to false to disable this logger without
  # deleting its configuration.
  IsEnabled: True

The code above uses the TextFile logger, which you also need to enable in your application by referencing the unit EF.Logger.TextFile (usually in your UseKitto.pas file). If you fail to include the relevant unit, your logging configuration will be ineffective.

Log levels

The Level parameter controls the verbosity of log output:

LevelDescription
1Minimal — errors and critical events only
2Warnings
3Informational messages
4Verbose
5Debug — full trace output

WARNING

Level: 5 generates huge amounts of data; use it only while debugging.

Available loggers

LoggerUnitConfig sectionDescription
TextFileEF.Logger.TextFileTextFileWrites to a plain text file
CodeSiteEF.Logger.CodeSiteCodeSiteSends log data to the CodeSite viewer (any edition)

Each logger section must contain at least IsEnabled: True. You can disable a logger without removing its configuration by setting IsEnabled: False. To log to file and CodeSite at the same time, just add both sections under the Log node.

Logging from your own code

If you need to log information from your server-side code (custom controllers, rules, tools), include the unit EF.Logger and call the methods of TEFLogger.Instance. Kittox takes care of thread synchronization.

Remember to enable at least one logger (e.g. reference EF.Logger.TextFile in your UseKitto.pas), otherwise the logged strings have nowhere to go.

Custom loggers

You can add your own custom loggers; just have a look at the predefined ones and use them as examples and starting points.

Basically you need to create a log endpoint: create a new class inherited from TEFLogEndpoint and override the DoLog method (don't forget the initialization and finalization sections in your unit, which will make your new class available to the system).

Released under Apache License, Version 2.0.