Hide menu
Loading...
Searching...
No Matches
Logging Support

Overview

Manufacturing toolkit provides built-in logging functionality that can be used to trace execution, analyze behavior, and debug issues. Logging is handled through a global singleton instance: Utilities.Logger.Instance() .

The logger filters messages based on severity levels (Utilities.LoggerLevel ) and dispatches accepted messages to registered handlers.

Message delivery is synchronous, meaning execution continues only after all handlers have processed the message.

Message severity level

Message level is defined by an enumeration Utilities.LoggerLevel . The following levels are supported (given in the order of decreasing severity):

  • Fatal
  • Error
  • Warning
  • Info
  • Debug
  • Trace

Utilities.Logger.SetLevel() sets a threshold level for the messages which should be accepted by the logger. The messages sent with the same or greater level are accepted, the ones with a lower level are ignored.

The Debug and Trace levels are reserved for internal purposes and should not be used by the MTK users.

Quick Start

var aLogger = Logger.Instance;
aLogger.SetLevel(LoggerLevel.Info);
var aHandler = new LoggerFileHandler("c:/temp/1.log");
aLogger.Register(aHandler, LoggerLevel.Info, LoggerLevel.Fatal);
Sends logging messages to a file.
Definition LoggerFileHandler.cs:21
Definition Logger.cs:50
void SetLevel(cadex.Utilities.LoggerLevel theLevel)
Sets message severity level.
Definition Logger.cs:158
static Logger Instance()
Returns a global logger.
Definition Logger.cs:199
Contains utility classes that can be useful for debugging or configuring global settings.
Definition JSONSerializer.cs:12
LoggerLevel
Definition LoggerLevel.cs:14

Environment Variables

Variable Effect
MTK_LOG_FILE Enables logging to the specified file (absolute path required).

Handlers

Handlers are responsible for processing log messages. They implement the Utilities.LoggerHandler interface. The MTK provides the following built-in handlers:

Handlers are executed in the order they are registered. They must be unregistered before destruction.