All Products
Search
Document Center

IoT Platform:View logs

Last Updated:Mar 27, 2023

After you run the sample code to connect a device with IoT Platform over HTTPS, After you use the sample code to connect a device to IoT Platform over Message Queuing Telemetry Transport (MQTT), you can view logs on the device

Prerequisites

The sample code in Link SDK for C is configured. Example.

Device logs

You can view the running result on the device.
  • Device connection logs

    The following log data indicates that the device is connected to IoT Platform.
    core_sysdep_network_establish host iot-as-http.cn-shanghai.aliyuncs.com port 443, type 0
    establish tcp connection with server(host='iot-as-http.cn-shanghai.aliyuncs.com', port=[443])
    success to establish tcp, fd=3
    local port: 56028
    [1621563692.299][LK-1000] establish mbedtls connection with server(host='iot-as-http.cn-shanghai.aliyuncs.com', port=[443])
    [1621563692.300][LK-1000] success to establish mbedtls connection, (cost 44722 bytes in total, max used 47410 bytes)
    [1621563692.300][LK-040B] > POST /auth?_v=sdk-c-4.1.0& HTTP/1.1
    [1621563692.300][LK-040B] > Host: iot-as-http.cn-shanghai.aliyuncs.com
    [1621563692.300][LK-040B] > Content-Type: application/json
    [1621563692.300][LK-040B] > Content-Length: 192
    [1621563692.300][LK-040B] >
    [LK-040C] > 7B 22 63 6C 69 65 6E 74  49 64 22 3A 22 61 31 77 | {"clientId":"a1w
    [LK-040C] > 41 66 49 55 6C 41 39 4E  2E 4C 69 67 68 74 53 77 | Af******.LightSw
    [LK-040C] > 69 74 63 68 22 2C 22 73  69 67 6E 6D 65 74 68 6F | itch","signmetho
    [LK-040C] > 64 22 3A 22 68 6D 61 63  73 68 61 32 35 36 22 2C | d":"hmacsha256",
    [LK-040C] > 22 64 65 76 69 63 65 4E  61 6D 65 22 3A 22 4C 69 | "deviceName":"Li
    [LK-040C] > 67 68 74 53 77 69 74 63  68 22 2C 22 70 72 6F 64 | ghtSwitch","prod
    [LK-040C] > 75 63 74 4B 65 79 22 3A  22 61 31 77 41 66 49 55 | uctKey":"a1wAf**
    [LK-040C] > 6C 41 39 4E 22 2C 22 73  69 67 6E 22 3A 22 41 36 | ****","sign":"A6
    [LK-040C] > 43 30 32 31 32 42 44 42  33 39 45 32 36 35 38 39 | C0212BDB39E26589
    [LK-040C] > 36 41 39 41 43 36 34 36  44 33 35 46 39 33 31 43 | 6A9AC646D35F931C
    [LK-040C] > 36 46 35 32 37 36 46 32  41 42 39 33 35 35 33 34 | 6F5276F2AB935534
    [LK-040C] > 30 37 42 31 46 45 33 39  43 31 33 35 37 46 22 7D | 07B1FE39******"}
    [1621563692.377][LK-040D] < HTTP/1.1 200
    [1621563692.377][LK-040D] < Server: nginx/1.14.2
    [1621563692.377][LK-040D] < Date: Fri, 21 May 2021 02:21:32 GMT
    [1621563692.377][LK-040D] < Content-Type: application/json
    [1621563692.377][LK-040D] < Content-Length: 82
    [1621563692.377][LK-040D] < Connection: keep-alive
    [1621563692.377][LK-040D] <
    [LK-040E] < 7B 22 63 6F 64 65 22 3A  30 2C 22 69 6E 66 6F 22 | {"code":0,"info"
    [LK-040E] < 3A 7B 22 74 6F 6B 65 6E  22 3A 22 5E 31 5E 31 36 | :{"token":"^1^16
    [LK-040E] < 32 31 35 36 33 36 39 32  33 36 34 5E 66 33 35 35 | 21563692364^f355
    [LK-040E] < 63 39 30 35 66 37 66 31  37 37 34 22 7D 2C 22 6D | c905f******"},"m
    [LK-040E] < 65 73 73 61 67 65 22 3A  22 73 75 63 63 65 73 73 | essage":"success
    [LK-040E] < 22 7D                                            | "}
    [1621563692.377][LK-0410] {"code":0,"info":{"token":"^1^1621563692364^f355c905f******"},"message":"success"}
    aiot_http_auth succeed
  • Logs about message sending

    After the connection is established, the following log data is printed. The log data indicates that the device uses a topic, for example, /a18wP******/LightSwitch/user/update, to send a message to IoT Platform.
    [1621563692.377][LK-040B] > POST /topic/a1wAf******/LightSwitch/user/update HTTP/1.1
    [1621563692.377][LK-040B] > Host: iot-as-http.cn-shanghai.aliyuncs.com
    [1621563692.377][LK-040B] > Content-Type: application/octet-stream
    [1621563692.377][LK-040B] > Password: ^1^1621563692364^f355c905f******
    [1621563692.377][LK-040B] > Content-Length: 53
    [1621563692.377][LK-040B] >
    [LK-040C] > 7B 22 69 64 22 3A 22 31  22 2C 22 76 65 72 73 69 | {"id":"1","versi
    [LK-040C] > 6F 6E 22 3A 22 31 2E 30  22 2C 22 70 61 72 61 6D | on":"1.0","param
    [LK-040C] > 73 22 3A 7B 22 4C 69 67  68 74 53 77 69 74 63 68 | s":{"LightSwitch
    [LK-040C] > 22 3A 30 7D 7D                                   | ":0}}
  • Logs about downstream response

    The following log data indicates that IoT Platform sends a response message to the device.
    [1621563692.477][LK-040D] < HTTP/1.1 200
    [1621563692.477][LK-040D] < Server: nginx/1.14.2
    [1621563692.477][LK-040D] < Date: Fri, 21 May 2021 02:21:32 GMT
    [1621563692.477][LK-040D] < Content-Type: application/json
    [1621563692.477][LK-040D] < Content-Length: 71
    [1621563692.477][LK-040D] < Connection: keep-alive
    [1621563692.477][LK-040D] <

IoT Platform logs

Log on to the IoT Platform console to view the device status and operation logs.

  • Device status

    In the left-side navigation pane, choose Devices > Devices. Then, find the device and view the device status. If the value in the State/Enabled column is Online, the device is connected to IoT Platform. View the device status