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

For more information, see 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.
    [1626837529.388][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1626837529.388][LK-0317] LightSwitch&a18wP******
    [1626837529.388][LK-0318] 6431725347995DC4FB7A24CC58FD297EEB6C712FC8662F88E54C8F23C0******
    core_sysdep_network_establish host iot-06******.mqtt.iothub.aliyuncs.com port 443, type 0
    establish tcp connection with server(host='iot-06******.mqtt.iothub.aliyuncs.com', port=[443])
    success to establish tcp, fd=3
    local port: 39072
    [1626837529.422][LK-1000] establish mbedtls connection with server(host='iot-06******.mqtt.iothub.aliyuncs.com', port=[443])
    [1626837529.488][LK-1000] success to establish mbedtls connection, (cost 44947 bytes in total, max used 47859 bytes)
    [1626837529.544][LK-0313] MQTT connect success in 161 ms
    AIOT_MQTTEVT_CONNECT
  • Logs generated when the device requests remote configuration information

    [1626837529.544][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/config/get
    
    [LK-030A] > 7B 22 69 64 22 3A 22 31  32 33 22 2C 22 70 61 72 | {"id":"123","par
    [LK-030A] > 61 6D 73 22 3A 7B 22 63  6F 6E 66 69 67 53 63 6F | ams":{"configSco
    [LK-030A] > 70 65 22 3A 22 70 72 6F  64 75 63 74 22 2C 22 67 | pe":"product","g
    [LK-030A] > 65 74 54 79 70 65 22 3A  22 66 69 6C 65 22 7D 7D | etType":"file"}}
  • Logs generated when IoT Platform returns a response message

    [1626837529.622][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/config/get_reply
    
    [LK-030A] < 7B 22 63 6F 64 65 22 3A  32 30 30 2C 22 64 61 74 | {"code":200,"dat
    [LK-030A] < 61 22 3A 7B 22 63 6F 6E  66 69 67 49 64 22 3A 22 | a":{"configId":"
    [LK-030A] < 66 36 35 32 31 65 66 64  33 31 66 39 34 31 37 61 | f6521efd31f9417a
    [LK-030A] < 62 63 37 38 30 38 39 66  34 63 37 38 62 36 38 36 | bc78089f4c******
    [LK-030A] < 22 2C 22 63 6F 6E 66 69  67 53 69 7A 65 22 3A 39 | ","configSize":9
    [LK-030A] < 33 34 2C 22 67 65 74 54  79 70 65 22 3A 22 66 69 | 34,"getType":"fi
    [LK-030A] < 6C 65 22 2C 22 73 69 67  6E 22 3A 22 63 39 36 34 | le","sign":"c964
    [LK-030A] < 34 65 62 32 63 39 64 36  34 38 38 39 34 32 65 32 | 4eb2c9d6488942e2
    [LK-030A] < 61 37 66 30 32 38 38 38  32 66 38 30 38 39 30 39 | a7f028882f808909
    [LK-030A] < 32 62 32 31 31 39 33 63  35 39 63 34 34 65 36 62 | 2b21193c59c44e6b
    [LK-030A] < 36 32 65 63 37 38 63 38  39 36 64 39 22 2C 22 73 | 62ec78******","s
    [LK-030A] < 69 67 6E 4D 65 74 68 6F  64 22 3A 22 53 68 61 32 | ignMethod":"Sha2
    [LK-030A] < 35 36 22 2C 22 75 72 6C  22 3A 22 68 74 74 70 73 | 56","url":"https
    [LK-030A] < 3A 2F 2F 6F 74 78 2D 64  65 76 69 63 65 63 65 6E | ://otx-devicecen
    [LK-030A] < 74 65 72 2D 74 68 69 6E  67 2D 63 6F 6E 66 69 67 | ter-thing-config
    [LK-030A] < 2D 63 6E 2D 73 68 61 6E  67 68 61 69 2D 6F 6E 6C | -cn-shanghai-onl
    [LK-030A] < 69 6E 65 2E 6F 73 73 2D  63 6E 2D 73 68 61 6E 67 | ine.oss-cn-shang
    [LK-030A] < 68 61 69 2E 61 6C 69 79  75 6E 63 73 2E 63 6F 6D | hai.aliyuncs.com
    [LK-030A] < 2F 67 37 68 30 33 32 4B  57 57 49 37 2F 74 68 69 | /a1wP******/thi
    [LK-030A] < 6E 67 43 6F 6E 66 69 67  2F 31 36 32 36 37 37 38 | ngConfig/1626778
    [LK-030A] < 37 30 33 38 33 32 5F 4B  7A 6B 51 76 77 58 34 3F | 703832_Kz******?
    [LK-030A] < 45 78 70 69 72 65 73 3D  31 36 32 36 38 33 39 33 | Expires=16268393
    [LK-030A] < 32 39 26 4F 53 53 41 63  63 65 73 73 4B 65 79 49 | 29&OSSAccessKeyI
    [LK-030A] < 64 3D 4C 54 41 49 52 59  33 72 78 35 64 67 32 4A | d=LTAIRY3rx5****
    [LK-030A] < 42 6D 26 53 69 67 6E 61  74 75 72 65 3D 37 5A 71 | **&Signature=7Zq
    [LK-030A] < 33 7A 50 31 70 4E 35 50  72 45 33 78 58 4F 56 49 | 3zP1pN5PrE3xXOVI
    [LK-030A] < 36 53 6E 69 35 4C 7A 38  25 33 44 22 7D 2C 22 69 | 6Sni5******"},"i
    [LK-030A] < 64 22 3A 22 31 32 33 22  2C 22 6D 65 74 68 6F 64 | d":"123","method
    [LK-030A] < 22 3A 22 74 68 69 6E 67  2E 63 6F 6E 66 69 67 2E | ":"thing.config.
    [LK-030A] < 67 65 74 22 2C 22 76 65  72 73 69 6F 6E 22 3A 22 | get","version":"
    [LK-030A] < 31 2E 30 22 7D                                   | 1.0"}
    
    configId: f6521efd31f9417abc78089f4c******, configSize: 934 Bytes
    core_sysdep_network_establish host otx-devicecenter-thing-config-cn-shanghai-online.oss-cn-shanghai.aliyuncs.com port 443, type 0
    establish tcp connection with server(host='otx-devicecenter-thing-config-cn-shanghai-online.oss-cn-shanghai.aliyuncs.com', port=[443])
    success to establish tcp, fd=4
    local port: 58534
  • Logs generated when the device downloads a configuration file

    
    [1626837529.688][LK-1000] establish mbedtls connection with server(host='otx-devicecenter-thing-config-cn-shanghai-online.oss-cn-shanghai.aliyuncs.com', port=[4
    [1626837529.755][LK-1000] success to establish mbedtls connection, (cost 47240 bytes in total, max used 49896 bytes)
    [1626837529.755][LK-040B] > GET /a1wP******/thingConfig/1626778703832_Kz******?Expires=1626839329&OSSAccessKeyId=LTAIRY3rx5******&Signature=7Zq3zP1pN5PrE******
    [1626837529.755][LK-040B] > Host: otx-devicecenter-thing-config-cn-shanghai-online.oss-cn-shanghai.aliyuncs.com
    [1626837529.755][LK-040B] > Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8
    [1626837529.755][LK-040B] > Range: bytes=0-
    [1626837529.755][LK-040B] > Content-Length: 0
    [1626837529.755][LK-040B] >
    [1626837529.755][LK-0309] pub: /ota/device/progress/a1wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 31 2C  20 22 70 61 72 61 6D 73 | {"id":1, "params
    [LK-030A] > 22 3A 7B 22 73 74 65 70  22 3A 22 30 22 2C 22 64 | ":{"step":"0","d
    [LK-030A] > 65 73 63 22 3A 22 22 7D  7D                      | esc":""}}
    
    [1626837529.811][LK-040D] < HTTP/1.1 206 Partial Content
    [1626837529.811][LK-040D] < Server: AliyunOSS
    [1626837529.811][LK-040D] < Date: Wed, 21 Jul 2021 03:18:49 GMT
    [1626837529.811][LK-040D] < Content-Type: application/octet-stream
    [1626837529.811][LK-040D] < Content-Length: 934
    [1626837529.811][LK-040D] < Connection: keep-alive
    [1626837529.811][LK-040D] < x-oss-request-id: 60F792193D168E3232******
    [1626837529.811][LK-040D] < Content-Range: bytes 0-933/934
    [1626837529.811][LK-040D] < Accept-Ranges: bytes
    [1626837529.811][LK-040D] < ETag: "BA0DD9490DFE76245C9B5F4C48******"
    [1626837529.811][LK-040D] < Last-Modified: Tue, 20 Jul 2021 10:58:23 GMT
    [1626837529.811][LK-040D] < x-oss-object-type: Normal
    [1626837529.811][LK-040D] < x-oss-hash-crc64ecma: 5008746007206******
    [1626837529.811][LK-040D] < x-oss-storage-class: Standard
    [1626837529.811][LK-040D] < Content-MD5: ug3ZSQ3+diRcm19M******==
    [1626837529.811][LK-040D] < x-oss-server-time: 56
    [1626837529.811][LK-040D] <
    [1626837529.811][LK-0901] digest matched
    [1626837529.811][LK-0309] pub: /ota/device/progress/a1wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 32 2C  20 22 70 61 72 61 6D 73 | {"id":2, "params
    [LK-030A] > 22 3A 7B 22 73 74 65 70  22 3A 22 31 30 30 22 2C | ":{"step":"100",
    [LK-030A] > 22 64 65 73 63 22 3A 22  22 7D 7D                | "desc":""}}
    
    config len is 934, config content is {"configId":"123dagdah","configSize":1234565,"sign":"123214adfadgadg","signMethod":"Sha256","url":"https://iotx-config.oss-cn-shanghai.aliyuncs.com/nopoll_0.4.4.tar.gz?Expires=1502955804&OSSAccessKeyId=**************&Signature=XfgJu7P6DWWejstKJgXJEH0q******&security-token=CAISuQJ1q6Ft5B2yfSjIpK6MGsyN1Jx5jo6mVnfBglIPTvlvt5D50Tz2IHtIf3NpAusdsv03nWxT7v4flqFyTINVAEvYZJOPKGrGR0DzDbDasumZsJbo4f%2FMQBqEaXPS2MvVfJ%2BzLrf0ceusbFbpjzJ6xaCAGxypQ12iN%2B%2Fr6%2F5gdc9FcQSkL0B8ZrFsKxBltdUROFbIKP%2BpKWSKuGfLC1dysQcO1wEP4K%2BkkMqH8Uic3h%2Boy%2BgJt8H2PpHhd9NhXuV2WMzn2%2FdtJOiTknxR7ARasaBqhelc4zqA%2FPPlWgAKvkXba7aIoo01fV4jN5JXQfAU8KLO8tRjofHWmojNzBJAAPpYSSy3Rvr7m5efQrrybY1lLO6iZy%2BVio2VSZDxshI5Z3McKARWct06MWV9ABA2TTXXOi40BOxuq%2B3JGoABXC54TOlo7%2F1wTLTsCUqzzeIiXVOK8CfNOkfTucMGHkeYeCdFkm%2FkADhXAnrnGf5a4FbmKMQph2cKsr8y8UfWLC6IzvJsClXTnbJBMeuWIqo5zIynS1pm7gf%2F9N3hVc6%2BEeIk0xfl2tycsUpbL2FoaGk6BAF8hWSWYUXsv59d******","getType":"file"}
    [1626837529.811][LK-1000] adapter_network_deinit

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
  • Logs about remote configuration

    In the left-side navigation pane, choose Maintenance > Device Log. Select a product to Select a product to view the logs that are generated when the device requests remote configuration information, downloads a remote configuration file, and then submits the downloading progress.