Skip to content

Bus Logger Component

The Bus Logger component supports various logging levels and logs messages to a topic on the Bus. Whereas the Logger component logs to console, a file or a UDP socket, logging to the bus allows log messages to be exported using the MQTT Bridge or REST Exporter.

As with the Logger component, 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 should be investigated, as they are likely to lead to the system not performing as configured
  • Warning. This logs all potentially harmful, unexpected events, such as a repeated failure to invoke a service. These events should also be investigated, as they may be the root cause of subsequent Errors
  • 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

Log messages generated by this component contain the following information

  • component. The name of this instance of the Bus Logger component, which is configurable
  • timestamp. The time at which the log message was triggered
  • severity. The log level, as described above
  • message. The log message as generated by the component using this Bus Logger

Configuration

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

Parameter Type Description Valid Values Required
Name String Specifies the name of this Bus Logger component Any string Y
Bus String The name of the Bus component to use The name of an existing Bus component 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 topic for the log A valid topic name Y
Next String Specifies the name of the next logger in a chain The name of another Logger or Bus 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 Bus Logger component called logbus, which logs only Errors to the xrt/notifications topic:

{
  "Library": "libxrt-bus-logger.so",
  "Factory": "xrt_bus_logger_factory",
  "Name":"logbus",
  "Level":"Error",
  "Bus":"bus",
  "To":"xrt/notifications"
}

The Bus Logger may be used in combination with the Logger. The following Logger configuration outputs all log messages at Debug and higher levels to a file, and also duplicates them to the Bus Logger component configured above.

{
  "Name": "logger",
  "To": "file:./xrt.log",
  "Level": "Debug",
  "Next": "logbus"
}