日志上报功能的例程运行后,您可以在设备端和物联网平台查看日志信息

前提条件

已配置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中的状态码描述根据提示解决问题。若未能解决问题,您可以提交工单