Logging¶
To create log messages the RTC Toolkit makes use of the well-established log4cplus logging API which will also used by the CII Logging service.
For each RTC Component a default logger with a consistent configuration is created, the name of this logger corresponds to the component instance name. Developers are free to make use of this default logger or to create additional loggers using the toolkit-provided API methods.
Note
To ensure a consistent and uniform log message format across all the instruments it is strongly recommended to make use of the toolkit-provided logging API rather than defining custom log.properties config files. This will greatly simplify collection and parsing of logfiles by other tools.
API Usage¶
The following header file must be included to be able to use the logging API:
#include "rtctk/componentFramework/logger.hpp"
Log messages can be created using the default log4cplus logging macros and the toolkit-provided
method GetLogger() which retrieves the component’s default logger when called without argument.
using rtctk::componentFramework::GetLogger;
LOG4CPLUS_INFO(GetLogger(), "My log message.");
Custom Loggers must be created explicitly using the MakeLogger() method, after creation
they can be used by retrieving the respective logger instance by name:
using rtctk::componentFramework::MakeLogger;
MakeLogger("my_logger", log4cplus::INFO_LOG_LEVEL);
using rtctk::componentFramework::GetLogger;
LOG4CPLUS_INFO(GetLogger("my_logger"), "My log message.");
Generated log messages can either be viewed on the console or in the generated log files.
By default a log file will be created for each RTC Component instance in directory
$INTROOT/logsink/.
The standard format for log messages is toolkit-defined and currently includes time-stamp, severity, logger-name and log message. Here an example:
[17:22:30:158][INFO ][my_logger] My log message.
Note
There are multiple ways to change the log-level: During component startup it can be defined
during logger creation with MakeLogger(), later it can be overwritten using API function
GetLogger().setLogLevel(). During runtime it can be adjusted using the rtctkClient
application with command SetLogLevel.
Limitations and Known Issues¶
Since the CII Logging service is not yet fully integrated into the supported ELT Development Environment versions, the RTC Tk makes direct use of log4cplus at the moment.
In the future this will change to get fully in line with the CII Logging service.