All Products
Search
Document Center

IoT Platform:View logs

Last Updated:Jul 07, 2023

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.

    [1624012656.944][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1624012656.944][LK-0317] LightSwitch&a18wP******
    [1624012656.944][LK-0318] ADE0BBAA0DFAC1CA3440DAB1D8B555EFD6E0AA0546A2312D0E1E1A60A******
    [1581401572.800][LK-0319] a18wP******.LightSwitch|timestamp=2524608000000,_ss=1,_v=sdk-c-4.0.0,securemode=2,signmethod=hmacsha256,ext=1,|
    establish mbedtls connection with server(host='a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com', port=[443])
    success to establish tcp, fd=3
    local port: 43014
    [1624012657.133][LK-0313] MQTT connect success in 184 ms
    AIOT_MQTTEVT_CONNECT
  • Topic subscription logs

    If you configure the code to subscribe to a topic, the following log data is printed. The log data indicates that the device subscribes to the /sys/a18wP******/LightSwitch/thing/event/property/batch/post_reply topic.

    [1624012657.133][LK-0309] sub: /sys/a18wP******/LightSwitch/thing/event/property/batch/post_reply
  • Logs about message sending

    • The following log data indicates that the device uses the default TSL module to submit a property:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/property/post
      
      [LK-030A] > 7B 22 69 64 22 3A 22 31  22 2C 22 76 65 72 73 69 | {"id":"1","versi
      [LK-030A] > 6F 6E 22 3A 22 31 2E 30  22 2C 22 70 61 72 61 6D | on":"1.0","param
      [LK-030A] > 73 22 3A 7B 22 4C 69 67  68 74 53 77 69 74 63 68 | s":{"LightSwitch
      [LK-030A] > 22 3A 20 30 7D 2C 22 73  79 73 22 3A 7B 22 61 63 | ": 0},"sys":{"ac
      [LK-030A] > 6B 22 3A 31 7D 7D                                | k":1}}
    • The following log data indicates that the device uses the default TSL module to submit an event:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/Error/post
      
      [LK-030A] > 7B 22 69 64 22 3A 22 32  22 2C 22 76 65 72 73 69 | {"id":"2","versi
      [LK-030A] > 6F 6E 22 3A 22 31 2E 30  22 2C 22 70 61 72 61 6D | on":"1.0","param
      [LK-030A] > 73 22 3A 7B 22 45 72 72  6F 72 43 6F 64 65 22 3A | s":{"ErrorCode":
      [LK-030A] > 20 30 7D 2C 22 73 79 73  22 3A 7B 22 61 63 6B 22 |  0},"sys":{"ack"
      [LK-030A] > 3A 31 7D 7D                                      | :1}}
    • The following log data indicates that the device uses the demo_extra_block custom module to submit a property:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/property/post
      
      [LK-030A] > 7B 22 69 64 22 3A 22 33  22 2C 22 76 65 72 73 69 | {"id":"3","versi
      [LK-030A] > 6F 6E 22 3A 22 31 2E 30  22 2C 22 70 61 72 61 6D | on":"1.0","param
      [LK-030A] > 73 22 3A 7B 22 64 65 6D  6F 5F 65 78 74 72 61 5F | s":{"demo_extra_
      [LK-030A] > 62 6C 6F 63 6B 3A 4E 69  67 68 74 4C 69 67 68 74 | block:NightLight
      [LK-030A] > 53 77 69 74 63 68 22 3A  20 31 7D 2C 22 73 79 73 | Switch": 1},"sys
      [LK-030A] > 22 3A 7B 22 61 63 6B 22  3A 31 7D 7D             | ":{"ack":1}}
    • The following log data indicates that the device uses the default TSL module to submit multiple properties:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/property/batch/post
      
      [LK-030A] > 7B 22 69 64 22 3A 22 34  22 2C 22 76 65 72 73 69 | {"id":"4","versi
      [LK-030A] > 6F 6E 22 3A 22 31 2E 30  22 2C 22 70 61 72 61 6D | on":"1.0","param
      [LK-030A] > 73 22 3A 7B 22 70 72 6F  70 65 72 74 69 65 73 22 | s":{"properties"
      [LK-030A] > 3A 7B 22 50 6F 77 65 72  22 3A 20 5B 20 7B 22 76 | :{"Power": [ {"v
      [LK-030A] > 61 6C 75 65 22 3A 22 6F  6E 22 2C 22 74 69 6D 65 | alue":"on","time
      [LK-030A] > 22 3A 31 36 31 32 36 38  34 35 31 38 7D 5D 2C 22 | ":1612684518}],"
      [LK-030A] > 57 46 22 3A 20 5B 7B 22  76 61 6C 75 65 22 3A 20 | WF": [{"value":
      [LK-030A] > 33 2C 22 74 69 6D 65 22  3A 31 36 31 32 36 38 34 | 3,"time":1612684
      [LK-030A] > 35 31 38 7D 5D 7D 7D 2C  22 73 79 73 22 3A 7B 22 | 518}]}},"sys":{"
      [LK-030A] > 61 63 6B 22 3A 31 7D 7D                          | ack":1}}
  • Logs about downstream response

    The following log data indicates that IoT Platform sends a response to the device:

    [1624012657.188][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/property/post_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 7D 2C 22 69  64 22 3A 22 31 22 2C 22 | a":{},"id":"1","
    [LK-030A] < 6D 65 73 73 61 67 65 22  3A 22 73 75 63 63 65 73 | message":"succes
    [LK-030A] < 73 22 2C 22 6D 65 74 68  6F 64 22 3A 22 74 68 69 | s","method":"thi
    [LK-030A] < 6E 67 2E 65 76 65 6E 74  2E 70 72 6F 70 65 72 74 | ng.event.propert
    [LK-030A] < 79 2E 70 6F 73 74 22 2C  22 76 65 72 73 69 6F 6E | y.post","version
    [LK-030A] < 22 3A 22 31 2E 30 22 7D                          | ":"1.0"}
    
    [1624012657.188][LK-0A08] DM recv generic reply
    demo_dm_recv_handler, type = 0
    msg_id = 1, code = 200, data = {}, message = success
    [1624012657.199][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/property/post_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 7D 2C 22 69  64 22 3A 22 33 22 2C 22 | a":{},"id":"3","
    [LK-030A] < 6D 65 73 73 61 67 65 22  3A 22 73 75 63 63 65 73 | message":"succes
    [LK-030A] < 73 22 2C 22 6D 65 74 68  6F 64 22 3A 22 74 68 69 | s","method":"thi
    [LK-030A] < 6E 67 2E 65 76 65 6E 74  2E 70 72 6F 70 65 72 74 | ng.event.propert
    [LK-030A] < 79 2E 70 6F 73 74 22 2C  22 76 65 72 73 69 6F 6E | y.post","version
    [LK-030A] < 22 3A 22 31 2E 30 22 7D                          | ":"1.0"}
    
    [1624012657.199][LK-0A08] DM recv generic reply
    demo_dm_recv_handler, type = 0
    msg_id = 3, code = 200, data = {}, message = success
    [1624012657.200][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/Error/post_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 7D 2C 22 69  64 22 3A 22 32 22 2C 22 | a":{},"id":"2","
    [LK-030A] < 6D 65 73 73 61 67 65 22  3A 22 73 75 63 63 65 73 | message":"succes
    [LK-030A] < 73 22 2C 22 6D 65 74 68  6F 64 22 3A 22 74 68 69 | s","method":"thi
    [LK-030A] < 6E 67 2E 65 76 65 6E 74  2E 45 72 72 6F 72 2E 70 | ng.event.Error.p
    [LK-030A] < 6F 73 74 22 2C 22 76 65  72 73 69 6F 6E 22 3A 22 | ost","version":"
    [LK-030A] < 31 2E 30 22 7D                                   | 1.0"}
  • Logs about property setting

    After the device is connected to IoT Platform, you can use one of the following methods to send a command to the device:

    After the device receives the command, a callback is called to perform the required operations. In this example, the command is printed. The following log data is printed:

    [1624246230.777][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/service/property/set
    
    [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 74 68 69 6E 67 | {"method":"thing
    [LK-030A] < 2E 73 65 72 76 69 63 65  2E 70 72 6F 70 65 72 74 | .service.propert
    [LK-030A] < 79 2E 73 65 74 22 2C 22  69 64 22 3A 22 31 34 30 | y.set","id":"140
    [LK-030A] < 37 31 32 32 37 39 32 22  2C 22 70 61 72 61 6D 73 | 7122792","params
    [LK-030A] < 22 3A 7B 22 4C 69 67 68  74 53 77 69 74 63 68 22 | ":{"LightSwitch"
    [LK-030A] < 3A 30 7D 2C 22 76 65 72  73 69 6F 6E 22 3A 22 31 | :0},"version":"1
    [LK-030A] < 2E 30 2E 30 22 7D                                | .0.0"}
    
    [1624246230.777][LK-0A08] DM recv property set
    demo_dm_recv_handler, type = 1
    msg_id = 1407122792, params = {"LightSwitch":0}
    [1624246230.777][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/service/property/set_reply
    
    [LK-030A] > 7B 22 69 64 22 3A 22 31  34 30 37 31 32 32 37 39 | {"id":"140712279
    [LK-030A] > 32 22 2C 22 63 6F 64 65  22 3A 32 30 30 2C 22 64 | 2","code":200,"d
    [LK-030A] > 61 74 61 22 3A 7B 7D 7D                          | ata":{}}

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

  • TSL data

    On the TSL Data tab of the Device Details page, view the submitted TSL data.

  • Operation logs

    In the left-side navigation pane, choose Maintenance > Device Log. Select a product to view the logs of the device that are generated when the device goes online, subscribes to the topic, and submits data to IoT Platform.

What's next

For more information about error messages in logs, see Common error codes or aiot_dm_api.h. You can troubleshoot errors based on the instructions.