Skip to content

Logger Component

The Logger component supports various logging levels and can be configured to support different back ends. A default global logger is supplied.

The supported log levels are as follows:

  • Error. This logs all error events that might still allow the application to run, such as failure to access a file. These events may require investigation at some point
  • Warning. This logs all potentially harmful, unexpected events, such as a repeated failure to invoke a service. These events probably require investigation
  • Information. This logs all high-level informational events that show the progress of the application, such as the start-up or stopping of a service. These events are milestones in normal operation and do not require any action
  • Debug. This logs more granular informational events. This is used when debugging an application or providing diagnostic information for an investigation
  • Trace. This logs fine-grained informational events and captures as much detail as possible. This is used when the debug level has not proved useful when diagnosing an issue and further detail is required

Logs can be timestamped, filtered and chained. The log messages can contain variable arguments.

You can use custom back ends, which can be for file or C standard output and error.

Configuration

The following table describes the configuration variables that can be used with the Logger component:

Parameter Type Description Valid Values Required
Name String Specifies the identifier to use for logging Y
Level String Specifies the level of information to log Valid values are as follows:
  • Error
  • Warn (default)
  • Info
  • Debug
  • Trace
N
To String Specifies the destination for the log

For example, a path and filename
A valid path and filename N
Next String Specifies the name of the next logger in a chain The name of an existing logger component N
Start Boolean Specifies whether to start on allocation

Specify true to start on allocation

Specify false to start the logger manually

Note: IoTech recommends that the logger is started on allocation (set to true) to allow the capturing of start-up events.
Valid values are as follows:
  • true (default)
  • false
N

Example Configuration

The following example configures a Logger component called file, which logs Warnings to the ./errors.log file:

{
  "Name": "file",
  "To": "file:./errors.log",
  "Level": "Warn"
}

Back to top