日誌上報功能的常式運行後,您可以在裝置端和物聯網平台查看日誌資訊。
前提條件
已配置C Link SDK的日誌上報功能的常式,詳細資料,請參見使用樣本。
裝置端日誌
您可以在裝置端查看運行結果。串連日誌:
出現如下日誌,表示裝置與物聯網平台串連成功。[1626431132.366][LK-0313] MQTT user calls aiot_mqtt_connect api, connect [1626431132.366][LK-0317] LightSwitch&a1wP****** [1626431132.366][LK-0318] 5C54B1B76214AC58DAB9F83927719D3340B105E20C40DDA68B659DF7E0****** 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: 38884 [1626431132.399][LK-1000] establish mbedtls connection with server(host='iot-06******.mqtt.iothub.aliyuncs.com', port=[443]) [1626431132.466][LK-1000] success to establish mbedtls connection, (cost 44947 bytes in total, max used 47859 bytes) [1626431132.466][LK-0319] a1wP******.LightSwitch|timestamp=2524608000000,_ss=1,_v=sdk-c-4.1.0,securemode=2,signmethod=hmacsha256,ext=3,_conn=tls_66| [1626431132.500][LK-0313] MQTT connect success in 146 ms AIOT_MQTTEVT_CONNECT
向物聯網平台發起日誌上報請求。
請求日誌:
[1626431132.500][LK-0309] pub: /sys/a1wP******/LightSwitch/thing/config/log/get [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 67 65 74 54 79 70 65 22 3A 22 63 | s":{"getType":"c [LK-030A] > 6F 6E 74 65 6E 74 22 2C 22 63 6F 6E 66 69 67 53 | ontent","configS [LK-030A] > 63 6F 70 65 22 3A 22 64 65 76 69 63 65 22 7D 7D | cope":"device"}} [1626431132.500][LK-1507] sys log config is on, toggle it using AIOT_LOGPOSTOPT_SYS_LOG.
- 應答報文日誌:
物聯網平台發回的應答報文日誌如下:
[1626431132.544][LK-0309] pub: /sys/a1wP******/LightSwitch/thing/config/log/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 74 65 6E 74 22 3A 7B 22 | a":{"content":{" [LK-030A] < 6D 6F 64 65 22 3A 31 7D 2C 22 67 65 74 54 79 70 | mode":1},"getTyp [LK-030A] < 65 22 3A 22 63 6F 6E 74 65 6E 74 22 7D 2C 22 69 | e":"content"},"i [LK-030A] < 64 22 3A 22 31 22 2C 22 6D 65 74 68 6F 64 22 3A | d":"1","method": [LK-030A] < 22 74 68 69 6E 67 2E 63 6F 6E 66 69 67 2E 6C 6F | "thing.config.lo [LK-030A] < 67 2E 67 65 74 22 2C 22 76 65 72 73 69 6F 6E 22 | g.get","version" [LK-030A] < 3A 22 31 2E 30 22 7D | :"1.0"} [1626431132.544][LK-1507] LOGPOST user log config arrived user log switch state is: 1 toggle it using the switch in device detail page in https://iot.console.aliyun.com
上報系統日誌:
[1626431132.500][LK-0309] pub: /sys/a1wP******/LightSwitch/thing/log/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 5B 7B 22 75 74 63 54 69 6D 65 22 3A 22 | s":[{"utcTime":" [LK-030A] > 32 30 32 31 2F 37 2F 31 36 20 31 38 3A 32 35 3A | 2021/7/16 18:25: [LK-030A] > 33 32 22 2C 22 6C 6F 67 4C 65 76 65 6C 22 3A 22 | 32","logLevel":" [LK-030A] > 49 4E 46 4F 22 2C 22 6D 6F 64 75 6C 65 22 3A 22 | INFO","module":" [LK-030A] > 6E 65 74 5F 63 6F 6E 6E 22 2C 22 63 6F 64 65 22 | net_conn","code" [LK-030A] > 3A 22 32 30 30 22 2C 22 74 72 61 63 65 43 6F 6E | :"200","traceCon [LK-030A] > 74 65 78 74 22 3A 22 30 22 2C 22 6C 6F 67 43 6F | text":"0","logCo [LK-030A] > 6E 74 65 6E 74 22 3A 22 74 69 6D 65 3D 31 36 32 | ntent":"time=162 [LK-030A] > 36 34 33 31 31 33 32 33 36 31 5E 63 6F 6E 6E 5F | 6431132361^conn_ [LK-030A] > 74 79 70 65 3D 54 4C 53 5E 63 6F 6E 6E 5F 63 6F | type=TLS^conn_co [LK-030A] > 73 74 3D 31 30 32 5E 63 6F 6E 6E 5F 72 65 74 3D | st=102^conn_ret= [LK-030A] > 30 22 7D 5D 7D | 0"}]} [1626431132.500][LK-1507] sys log config is on, toggle it using AIOT_LOGPOSTOPT_SYS_LOG.
上報業務日誌:
[1626431142.500][LK-0309] pub: /sys/a1wP******/LightSwitch/thing/log/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 5B 7B 22 75 74 63 54 69 6D 65 22 3A 22 | s":[{"utcTime":" [LK-030A] > 32 30 32 31 2F 37 2F 31 36 20 31 38 3A 32 35 3A | 2021/7/16 18:25: [LK-030A] > 34 32 22 2C 22 6C 6F 67 4C 65 76 65 6C 22 3A 22 | 42","logLevel":" [LK-030A] > 44 45 42 55 47 22 2C 22 6D 6F 64 75 6C 65 22 3A | DEBUG","module": [LK-030A] > 22 41 50 50 22 2C 22 63 6F 64 65 22 3A 22 32 30 | "APP","code":"20 [LK-030A] > 30 22 2C 22 74 72 61 63 65 43 6F 6E 74 65 78 74 | 0","traceContext [LK-030A] > 22 3A 22 30 22 2C 22 6C 6F 67 43 6F 6E 74 65 6E | ":"0","logConten [LK-030A] > 74 22 3A 22 6C 6F 67 20 69 6E 20 77 68 69 6C 65 | t":"log in while [LK-030A] > 28 31 29 22 7D 5D 7D | (1)"}]}
物聯網平台日誌
您可以在物聯網平台控制台,查看裝置的狀態和作業記錄。
線上狀態:
在左側導覽列,選擇
,找到裝置,查看裝置狀態。裝置狀態顯示為線上,則表示裝置與物聯網平台成功串連。作業記錄:
在左側導覽列,選擇 ,選擇產品後,單擊雲端作業記錄和裝置本地日誌,分別查看上報日誌過程中的雲端日誌以及上報的裝置本地日誌。- 雲端作業記錄:
- 裝置本地日誌:
後續步驟
作業記錄中出現的錯誤資訊,請參見aiot_logpost_api.h中的狀態代碼描述,根據提示解決問題。