Our example shows how to configure and obtain logs, using the Bosch IoT Gateway Software Log Service.
The section is structured as follows:
To work with Log Service the following expectations are assumed:
you went through all steps described at Getting started
you have a Bosch IoT Edge Services Runtime on your local machine.
Configure the logging service
By default, the framework is started with log information from the Framework Log and from the OSGi Log Service saved in files within the directory
It keeps information such as time, message, bundle caller, etc.
It implements the OSGi Log Service specification and extends it with new functionalities.
By means of system properties, various functionalities of the Framework Log can be configured like:
having the log information directed to the framework console, a log file, or a remote device;
storing logs and exceptions in a common file or separate files;
changing the number and size of the archived log files.
Refer to the Log Properties table at the official documentation for specific information.
Find your current log file
By default, the Framework Log is configured to save log information in files in the directory
These log files are no more than five, using the following naming pattern:
the current file is labelled log.txt,
the one preceding it is log0.txt, etc.
and the oldest one is log3.txt.
Upon a new file entering the Framework Log, the last one is deleted. In this way your current log file is always labelled log.txt.
Change the log level
Log messages are written in the most optimal way by the Logger Utility.
By default the level is set to 3 for receiving info messages.
However, the log level can be changed in accordance with any specific needs. All logs with log level less than or equal to the specified in the property will be logged in the correspondent log file.
When using an evaluation image of Bosch IoT Edge Services, the gsa_agent.prs file contains two entries:
0 - no debug
1 - error only
2 - warning
3 - info
4 - debug
5 - trace (additional debug)
Obtain the log entries you are interested in
Logs can be observed in two ways:
via the Bosch IoT Edge Services text console:
enter the log group by executing cd log
list all received logs by executing ls
Find details at Working with the text console
via the Bosch IoT Edge Services web console:
Navigate to OSGi > Log Service
Find details at Viewing Framework Logs, part of Working with the Web Console
In case you need to download your log files, click Status > Log files.
Getting filtered log messages is possible via the Log Filter Service.
It is available under the interface name com.prosyst.mbs.services.log.LogFilter, and provides the methods getLogsByID and getLogsByTIme.
If you have difficulties viewing your logs, go through the following:
Check if the specific folder actually contains a log file.
Confirm that com.prosyst.mbs.osgi.log.bundle.jar is present in the bundles folder and is started.
Check if all needed log properties are properly configured.
Check the levels of your log properties in the corresponding .prs file (set it to 3 to receive info messages).
Ensure that the Log Service is registered and that no time-period restrictions are active.