Device logs
Device logs are visible in the nRF Cloud portal or APIs.
Requirements
An nRF91 Series device
One of the supported samples. These samples are preconfigured to support nRF Cloud logs.
Using device logs in the nRF Cloud portal
To enable, disable, or change the level of logs:
Log in to the nRF Cloud portal.
Select Device Management in the left sidebar.
A pane opens to the right.
Select Devices.
Navigate to the page of the device.
Find the Logs card.
The header of the Logs card shows the current log level.
Select the desired log level from the drop-down menu.
It may take some time for the log level change request to finish processing. If the device is not connected when you change the log level in the portal, it will process the change request when it reconnects to nRF Cloud.
Once the request finishes processing, the current log level updates to match the requested one.
Viewing logs
To view logs and download data:
From the device page, find the Logs card.
If the device is currently connected, the card shows current logs.
To view historical log data:
Click the triangular clock icon in the lower right corner of the Logs card.
The time selector opens.
Select a time range from the drop-down menu.
Click Get data.
Logs within the specified time range appear in the card. Click the cloud icon to download logs for that range as a CSV file.
Messages in logs might not be in chronological order.
Using device logs through the APIs
Device messages with log data are sent over supported message topics or through the SendDeviceMessage
endpoint. Messages are stored on nRF Cloud for 30 days.
To enable, disable, or change the level of logs, call the UpdateDeviceState
endpoint. The following sections give examples for each of these cases.
Enabling logs
Specify a log level of 1
(error), 2
(warning), 3
(info), or 4
(debug) in the desired... control... logLvl
field:
{
"desired": {
"control": {
"logLvl": 2
}
}
}
Disabling logs
Specify the log level 0
in the desired... control... logLvl
field:
{
"desired": {
"control": {
"logLvl": 0
}
}
}
Changing the log level
Specify the desired log level in the desired... control... logLvl
field:
{
"desired": {
"control": {
"logLvl": 3
}
}
}
See the overview for available log levels.
Viewing logs
To view device logs, call the ListMessages
endpoint. To view only messages related to device logs, include the query parameter appId=LOG
.
Messages in the response might not be in chronological order.
See the endpoint reference for more information on optional filters. See also Device messages.
The following example response includes appId: "LOG"
:
"items": [
{
"topic": "<environment>/7c57d43f-4307-4d8a-86fe-a14294f1ce93/m/d/nrf-350457790035043/d2c",
"deviceId": "nrf-350423790035043",
"receivedAt": "2023-05-09T11:36:30.501Z",
"message": {
"appId": "LOG",
"dom": 0,
"lvl": 3,
"src": "application",
"ts": 1683632190501,
"seq": 217,
"msg": "Temperature is 23 degrees C"
},
"tenantId": "7c57d43f-4307-4d8a-86fe-a14294f1ce93"
},
]