All Products
Search
Document Center

IoT Platform:View logs

Last Updated:Oct 07, 2023

After you run a sample program to connect a device to IoT Platform over Message Queuing Telemetry Transport (MQTT) 5.0, you can view logs on the device or in the IoT Platform console.

Prerequisites

A sample program that is written based on Link SDK for C is configured and run. For more information, see Example.

Device logs

You can view the execution result on the device.

  1. View connection logs.

    If the following logs are generated, a connection between the device and IoT Platform is established:

    [1680608104.988][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1680608104.988][LK-032A] mqtt host: a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com
    [1680608104.988][LK-0317] user name: LightSwitch&a18wP*******
    [1680608104.988][LK-0318] password: 4CEB5BA5B334CDB73DAAEEF97EBC1A09*******************
    success to establish tcp, fd=3
    local port: 34624
    [1680608104.999][LK-1000] establish mbedtls connection with server(host='a18wP*******.iot-as-mqtt.cn-shanghai.aliyuncs.com', port=[1883])
    [1680608105.066][LK-1000] success to establish mbedtls connection, (cost 45329 bytes in total, max used 48297 bytes)
    [1680608105.099][LK-0000] MQTT_PROP_ID_RECEIVE_MAXIMUM:10 
    [1680608105.099][LK-0000] MQTT_PROP_ID_TOPIC_ALIAS_MAXIMUM:20 
    [1680608105.099][LK-0000] MQTT_PROP_ID_MAXIMUM_QOS:1 
    [1680608105.099][LK-0000] MQTT_PROP_ID_RETAIN_AVAILABLE:1 
    [1680608105.099][LK-0000] MQTT_PROP_ID_MAXIMUM_PACKET_SIZE:262144 
    [1680608105.099][LK-0000] MQTT_PROP_ID_WILDCARD_SUBSCRIPTION_AVAILABLE:1 
    [1680608105.099][LK-0000] MQTT_PROP_ID_SUBSCRIPTION_IDENTIFIERS_AVAILABLE:0 
    [1680608105.099][LK-0000] MQTT_PROP_ID_SHARED_SUBSCRIPTION_AVAILABLE:1 
    [1680608105.099][LK-0000] MQTT_PROP_ID_SESSION_EXPIRY_INTERVAL:0 
    [1680608105.099][LK-0000] MQTT_PROP_ID_SERVER_KEEP_ALIVE:1200 
    [1680608105.099][LK-0313] MQTT connect success in 116 ms
  2. View logs about topic subscription.

    [1680608105.099][LK-0309] sub: /sys/a18wP******/LightSwitch/thing/event/property/post_reply
  3. View logs about message sending.

    [1680608105.099][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 30 7D 7D   

IoT Platform logs

You can 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.

  • 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 to do next

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