you can view logs on the device or in IoT Platform.

Prerequisites

For more information, see Example.

Device logs

You can view the running result on the device.
  • Logs about device connection

    The following log data indicates that the device is connected to IoT Platform.
    [1583135792.733][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1583135792.733][LK-0317] LightSwitch&a18wP******
    [1583135792.733][LK-0318] 3FC4A3DED5AC5F31C4969CBB1868758B17FAB2E5070FC51C9880910472******
    [1583135792.733][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 mbedtls connection, fd = 6(cost 44763 bytes in total, max used 47675 bytes)
    [1583135792.888][LK-0313] MQTT connect success in 147 ms
    AIOT_MQTTEVT_CONNECT
  • Logs about topic subscription

    If you want to send a broadcast message to all devices under a product, the devices must subscribe to the broadcast topic, such as /broadcast/a18wP******/test. After subscription, the following log data is generated:

    [1624933980.266][LK-0309] sub: /broadcast/a18wP******/test
    suback, res: -0x0000, packet id: 1, max qos: 1
  • Logs about message broadcasting

    • Send a broadcast message to a specified topic

      You can call the PubBroadcast operation of IoT Platform to send a broadcast message to a specified topic. The following log data indicates that the helloworld message is sent to the /broadcast/a18wP******/test topic:
      [1624934078.899][LK-0309] pub: /broadcast/a18wP******/test
      
      [LK-030A] < 68 65 6C 6C 6F 77 6F 72  6C 64                   | helloworld
      
      pub, qos: 0, topic: /broadcast/a18wP******/test
      pub, payload: helloworld
    • Send a broadcast message to all online devices

      You can also call the PubBroadcast operation of IoT Platform to send a broadcast message such as helloworld to all online devices under a specified product. In this example, the following log data is generated.
      • Log data:
        [1624934109.099][LK-0309] pub: /sys/a18wP******/LightSwitch/broadcast/request/1409701944049******
        
        [LK-030A] < 68 65 6C 6C 6F 77 6F 72  6C 64                   | helloworld
        
        pub, qos: 1, topic: /sys/a18wP******/LightSwitch/broadcast/request/1409701944049******
        pub, payload: helloworld
      • Log description:

        /sys/a18wP******/LightSwitch/broadcast/request/1409701944049****** indicates the topic to which the broadcast message is sent. 1213074107617****** indicates the message ID. For more information, see Broadcast messages.

IoT Platform logs

You can log on to the IoT Platform console . In the left-side navigation pane, choose Maintenance > Device Log. Select a product to Select a product and then view the communication logs of the device.

What to do next

For more information about error messages in logs, see Common error codes