Remotely collecting logs [Preview feature]
Device Management Client has an option to capture logs remotely from embedded devices. This feature is off by default.
To enable remote logging in Mbed OS devices, add this parameter in the application mbed_app.json
:
"mbed-client.dynamic-logging-buffer-size" : 4096
To enable remote logging in Linux, change the application's define.txt
:
add_definitions(-DMBED_CONF_MBED_CLIENT_DYNAMIC_LOGGING_BUFFER_SIZE=4096)
The dynamic-logging-buffer-size
variable defines the size of the logs stored in RAM before flushing those to NVM.
There are two operation modes:
- "Save All": The device collects all trace lines to the buffer and flushes the contents to NVM when the buffer is full.
- “Log on ERR/WARN”: The device monitors for ERR/WARN trace lines, and if they occur, flushes the current buffer content and the next full buffer to NVM. By default, the device monitors ERR lines.
Controling remote logging
Device Management Client publishes these resources to control remote logging:
- 33456/0/1: Executable resource to start log capture.
- 33456/0/2: Executable resource to stop log capture. Content of the log buffer is flushed to NVM when the capture is stopped even when the buffer isn't full.
- 33456/0/3: Readable resource to get stored logs.
- 33456/0/4: Executable resource to clear storage.
- 33456/0/5: Read/Write resource to set trace level output. The default value is the one chosen at build time. Accepted values are CMD (0), ERROR (1), WARN (2), INFO (3) and DEBUG(4).
- 33456/0/6: Read/Write resource to set trace level trigger. Accepted values are DISABLED(0), ERROR (1) and WARN (2). The default value is ERROR. If this resource is disabled, it works as defined in "Save all" mode.
- 33456/0/7: Read/Write resource to set storage size in bytes. The default is the whole update candidate image space.
- 33456/0/8: Read/Write resource to set auto erase flag. If this resoure is set, storage is erased automatically when it gets full, and the capture continues. If this resource isn't set, capture stops, the error "STORAGE FULL" is raised and user action is needed to continue. This resource is disabled by default.
- 33456/0/9: Read resource to check whether logging is enabled.
- 33456/0/10: Read resource to see the size in bytes of the unread logs in storage.
- 33456/0/11: Read resource to monitor error status. Possible values are SUCCESS(0), STORAGE FULL(1), READ FAILURE(2), WRITE FAILURE(3), ABORTED(4) and OUT OF MEMORY(5).
- 33456/0/12: Read resource to check how much storage in bytes the logs are consuming.
Limitations
Because remote logging uses the same storage space as the firmware update process, you can't use remote logging when the firmware update process is active. If remote logging is active when the firmware update process starts, remote logging stops and all stored logs are removed.