Running logs

Updated at:

After you run the device shadow example, you can view the logs on the device and in the IoT Platform console.

Background information

First, configure the C Link SDK device shadow example. For more information, see Use the example.

Device-side logs

You can view the running logs on the device.
  • Connection log

    [1626317181.277][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1626317181.277][LK-0317] LightSwitch&a1wP******
    [1626317181.277][LK-0318] 97B797D367BF307A0573979CF6CCA5675719F6790B361F2596E01B72AC******
    core_sysdep_network_establish host iot-06******.mqtt.iothub.aliyuncs.comuncs.com port 1883, type 0
    establish tcp connection with server(host='iot-06******.mqtt.iothub.aliyuncs.comuncs.com', port=[1883])
    success to establish tcp, fd=3
    local port: 38522
    [1626317181.300][LK-1000] establish mbedtls connection with server(host='iot-06******.mqtt.iothub.aliyuncs.comuncs.com', port=[1883])
    [1626317181.388][LK-1000] success to establish mbedtls connection, (cost 44947 bytes in total, max used 47859 bytes)
    [1626317181.388][LK-0319] a1wP******.LightSwitch|timestamp=2524608000000,_ss=1,_v=sdk-c-4.1.0,securemode=2,signmethod=hmacsha256,ext=3,_conn=tls_6b|
    [1626317181.433][LK-0313] MQTT connect success in 161 ms
    AIOT_MQTTEVT_CONNECT
  • Device reports its status:

    1. Log for reporting status to the device shadow:

      [1626317187.433][LK-0309] pub: /shadow/update/a1wP******/LightSwitch
      [LK-030A] > 7B 22 6D 65 74 68 6F 64  22 3A 22 75 70 64 61 74 | {"method":"update",
      [LK-030A] > 65 22 2C 22 73 74 61 74  65 22 3A 7B 22 72 65 70 | "state":{"rep
      [LK-030A] > 6F 72 74 65 64 22 3A 7B  22 4C 69 67 68 74 53 77 | orted":{"LightSw
      [LK-030A] > 69 74 63 68 22 3A 31 7D  7D 2C 22 76 65 72 73 69 | itch":1}},"versi
      [LK-030A] > 6F 6E 22 3A 30 7D                                | on":0}
    2. Response message log:

      [1626317187.477][LK-0309] pub: /shadow/get/a1wP******/LightSwitch
      [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 72 65 70 6C 79 | {"method":"reply
      [LK-030A] < 22 2C 22 70 61 79 6C 6F  61 64 22 3A 7B 22 73 74 | ","payload":{"st
      [LK-030A] < 61 74 75 73 22 3A 22 73  75 63 63 65 73 73 22 2C | atus":"success",
      [LK-030A] < 22 76 65 72 73 69 6F 6E  22 3A 30 7D 2C 22 63 6C | "version":0},"cl
      [LK-030A] < 69 65 6E 74 54 6F 6B 65  6E 22 3A 22 6E 75 6C 6C | ientToken":"null
      [LK-030A] < 22 2C 22 74 69 6D 65 73  74 61 6D 70 22 3A 31 36 | ","timestamp":16
      [LK-030A] < 32 36 33 31 37 31 38 37  7D                      | 26317187}
      [1626317187.477][LK-1304] SHADOW recv get_reply message
      demo_shadow_recv_handler, type = 0, productKey = a1wP******, deviceName = LightSwitch
      payload = "{"status":"success","version":0}", status = success, timestamp = 1626317187
  • Application changes device status:
    1. Log for a desired property from IoT Platform:

      For example, IoT Platform sends a message that contains the desired property {"LightSwitch":0}. After the device receives the message, the following log is printed.

      [1626319658.166][LK-0309] pub: /shadow/get/a1wP******/LightSwitch
      [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 63 6F 6E 74 72 | {"method":"contr
      [LK-030A] < 6F 6C 22 2C 22 70 61 79  6C 6F 61 64 22 3A 7B 22 | ol","payload":{"
      [LK-030A] < 73 74 61 74 65 22 3A 7B  22 64 65 73 69 72 65 64 | state":{"desired
      [LK-030A] < 22 3A 7B 22 4C 69 67 68  74 53 77 69 74 63 68 22 | ":{"LightSwitch"
      [LK-030A] < 3A 30 7D 7D 2C 22 6D 65  74 61 64 61 74 61 22 3A | :0}},"metadata":
      [LK-030A] < 7B 22 64 65 73 69 72 65  64 22 3A 7B 22 4C 69 67 | {"desired":{"Lig
      [LK-030A] < 68 74 53 77 69 74 63 68  22 3A 7B 22 74 69 6D 65 | htSwitch":{"time
      [LK-030A] < 73 74 61 6D 70 22 3A 31  36 32 36 33 31 39 36 35 | stamp":162631965
      [LK-030A] < 38 7D 7D 7D 7D 2C 22 74  69 6D 65 73 74 61 6D 70 | 8}}}},"timestamp
      [LK-030A] < 22 3A 31 36 32 36 33 31  39 36 35 38 2C 22 76 65 | ":1626319658,"ve
      [LK-030A] < 72 73 69 6F 6E 22 3A 34  7D                      | rsion":0}
      [1626319658.166][LK-1304] SHADOW recv control message
      demo_shadow_recv_handler, type = 1, productKey = a1wP******, deviceName = LightSwitch
      payload = "{"state":{"desired":{"LightSwitch":0}},"metadata":{"desired":{"LightSwitch":{"timestamp":1626319658}}}}", version = 4
    2. Log for reporting the updated state:

      Important The sample code is for demonstration purposes only. In a production environment, you must write your own logic to process and automatically apply the received desired properties.
      [1626317203.433][LK-0309] pub: /shadow/update/a1wP******/LightSwitch
      [LK-030A] > 7B 22 6D 65 74 68 6F 64  22 3A 22 75 70 64 61 74 | {"method":"update",
      [LK-030A] > 65 22 2C 22 73 74 61 74  65 22 3A 7B 22 72 65 70 | "state":{"rep
      [LK-030A] > 6F 72 74 65 64 22 3A 7B  22 4C 69 67 68 74 53 77 | orted":{"LightSw
      [LK-030A] > 69 74 63 68 22 3A 31 7D  7D 2C 22 76 65 72 73 69 | itch":0}},"versi
      [LK-030A] > 6F 6E 22 3A 30 7D                                | on":1}
    3. Log for deleting desired properties:

      [1626320515.566][LK-0309] pub: /shadow/update/a1wP******/LightSwitch
      [LK-030A] > 7B 22 6D 65 74 68 6F 64  22 3A 22 75 70 64 61 74 | {"method":"update",
      [LK-030A] > 65 22 2C 22 73 74 61 74  65 22 3A 7B 22 64 65 73 | "state":{"des
      [LK-030A] > 69 72 65 64 22 3A 22 6E  75 6C 6C 22 7D 2C 22 76 | ired":"null"},"v
      [LK-030A] > 65 72 73 69 6F 6E 22 3A  35 7D                   | ersion":2}
                                  
    4. Response log for deleting desired properties:

      [1626320515.600][LK-0309] pub: /shadow/get/a1wP******/LightSwitch
      [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 72 65 70 6C 79 | {"method":"reply
      [LK-030A] < 22 2C 22 70 61 79 6C 6F  61 64 22 3A 7B 22 73 74 | ","payload":{"st
      [LK-030A] < 61 74 75 73 22 3A 22 73  75 63 63 65 73 73 22 2C | atus":"success",
      [LK-030A] < 22 76 65 72 73 69 6F 6E  22 3A 35 7D 2C 22 63 6C | "version":5},"cl
      [LK-030A] < 69 65 6E 74 54 6F 6B 65  6E 22 3A 22 6E 75 6C 6C | ientToken":"null
      [LK-030A] < 22 2C 22 74 69 6D 65 73  74 61 6D 70 22 3A 31 36 | ","timestamp":16
      [LK-030A] < 32 36 33 32 30 35 31 35  7D                      | 26320515}
      [1626320515.600][LK-1304] SHADOW recv get_reply message
      demo_shadow_recv_handler, type = 0, productKey = a1wP******, deviceName = LightSwitch
      payload = "{"status":"success","version":5}", status = success, timestamp = 1626320515
  • Device retrieves the device shadow content:
    • Request log for retrieving the device shadow:

      [1626320690.499][LK-0309] pub: /shadow/update/a1wP******/LightSwitch
      [LK-030A] > 7B 22 6D 65 74 68 6F 64  22 3A 22 67 65 74 22 7D | {"method":"get"}
    • Response message log:

      This log indicates that the desired and reported properties in the device shadow are empty.

      [1626320690.522][LK-0309] pub: /shadow/get/a1wP******/LightSwitch
      [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 72 65 70 6C 79 | {"method":"reply
      [LK-030A] < 22 2C 22 70 61 79 6C 6F  61 64 22 3A 7B 22 73 74 | ","payload":{"st
      [LK-030A] < 61 74 75 73 22 3A 22 73  75 63 63 65 73 73 22 2C | atus":"success",
      [LK-030A] < 22 73 74 61 74 65 22 3A  7B 22 72 65 70 6F 72 74 | "state":{"report
      [LK-030A] < 65 64 22 3A 7B 7D 7D 2C  22 6D 65 74 61 64 61 74 | ed":{}},"metadat
      [LK-030A] < 61 22 3A 7B 22 72 65 70  6F 72 74 65 64 22 3A 7B | a":{"reported":{
      [LK-030A] < 7D 7D 7D 2C 22 74 69 6D  65 73 74 61 6D 70 22 3A | }}},"timestamp":
      [LK-030A] < 31 36 32 36 33 32 30 36  39 30 2C 22 76 65 72 73 | 1626320690,"vers
      [LK-030A] < 69 6F 6E 22 3A 35 2C 22  63 6C 69 65 6E 74 54 6F | ion":5,"clientTo
      [LK-030A] < 6B 65 6E 22 3A 22 6E 75  6C 6C 22 7D             | ken":"null"}
      [1626320690.522][LK-1304] SHADOW recv generic_reply message
      demo_shadow_recv_handler, type = 2, productKey = a1wP******, deviceName = LightSwitch
      payload = "{"status":"success","state":{"reported":{}},"metadata":{"reported":{}}}", version = 5
  • Device deletes a reported property:
    1. Request log for deleting a reported property:

      This request log indicates a request to delete the LightSwitch reported property.

      [1626321049.222][LK-0309] pub: /shadow/update/a1wP******/LightSwitch
      [LK-030A] > 7B 22 6D 65 74 68 6F 64  22 3A 22 64 65 6C 65 74 | {"method":"delete",
      [LK-030A] > 65 22 2C 22 73 74 61 74  65 22 3A 7B 22 72 65 70 | "state":{"rep
      [LK-030A] > 6F 72 74 65 64 22 3A 7B  22 4C 69 67 68 74 53 77 | orted":{"LightSw
      [LK-030A] > 69 74 63 68 22 3A 22 6E  75 6C 6C 22 7D 7D 2C 22 | itch":"null"}},"
      [LK-030A] > 76 65 72 73 69 6F 6E 22  3A 39 7D                | version":2}
                                  
    2. Response message log:

      This log indicates that the deletion was successful.

      [1626321049.255][LK-0309] pub: /shadow/get/a1wP******/LightSwitch
      [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 72 65 70 6C 79 | {"method":"reply
      [LK-030A] < 22 2C 22 70 61 79 6C 6F  61 64 22 3A 7B 22 73 74 | ","payload":{"st
      [LK-030A] < 61 74 75 73 22 3A 22 73  75 63 63 65 73 73 22 2C | atus":"success",
      [LK-030A] < 22 76 65 72 73 69 6F 6E  22 3A 39 7D 2C 22 63 6C | "version":2},"cl
      [LK-030A] < 69 65 6E 74 54 6F 6B 65  6E 22 3A 22 6E 75 6C 6C | ientToken":"null
      [LK-030A] < 22 2C 22 74 69 6D 65 73  74 61 6D 70 22 3A 31 36 | ","timestamp":16
      [LK-030A] < 32 36 33 32 31 30 34 39  7D                      | 26321049}
      [1626321049.255][LK-1304] SHADOW recv get_reply message
      demo_shadow_recv_handler, type = 0, productKey = a1wP******, deviceName = LightSwitch
      payload = "{"status":"success","version":2}", status = success, timestamp = 1626321049

IoT Platform logs

You can view the device status and operational logs in the IoT Platform consol.

  • Online status

    In the navigation pane on the left, choose Device Management > Devices. Find the device and view its status. If the device status is Online, the device is connected to IoT Platform.查看设备状态

  • Operational logs

    In the left-side navigation pane, choose Monitoring and O&M > Simple Log Service. Select a product to view logs related to the device shadow. On the Cloud-Side Runtime Log tab, you can filter logs by criteria such as DeviceName, TraceId, Content Keyword, Status, and a time range. The log list displays information for each entry, including the time, TraceId, DeviceName, business type, operation path, and status code.