trace 命令

trace 命令用于追踪某个 Client 或 Topic,打印日志信息到文件,详情请查看 日志与追踪

命令描述
trace list列出所有开启的追踪
trace start client <ClientId> <File> [<Level>]开启 Client 追踪,存储指定等级的日志到文件
trace stop client <ClientId>关闭 Client 追踪
trace start topic <Topic> <File> [<Level>]开启 Topic 追踪,存储指定等级的日志到文件
trace stop topic <Topic>关闭 Topic 追踪

trace start client[]

开启 Client 追踪:

  1. $ ./bin/emqx_ctl log primary-level debug
  2. debug
  3. $ ./bin/emqx_ctl trace start client clientid log/clientid_trace.log
  4. trace clientid clientid successfully
  5. $ ./bin/emqx_ctl trace start client clientid2 log/clientid2_trace.log error
  6. trace clientid clientid2 successfully

trace stop client

关闭 Client 追踪:

  1. $ ./bin/emqx_ctl trace stop client clientid
  2. stop tracing clientid clientid successfully

trace start topic[]

开启 Topic 追踪:

  1. $ ./bin/emqx_ctl log primary-level debug
  2. debug
  3. $ ./bin/emqx_ctl trace start topic topic log/topic_trace.log
  4. trace topic topic successfully
  5. $ ./bin/emqx_ctl trace start topic topic2 log/topic2_trace.log error
  6. trace topic topic2 successfully

trace stop topic

关闭 Topic 追踪:

  1. $ ./bin/emqx_ctl trace topic topic off
  2. stop tracing topic topic successfully

trace list

列出所有开启的追踪:

  1. $ ./bin/emqx_ctl trace list
  2. Trace (clientid=clientid2, level=error, destination="log/clientid2_trace.log")
  3. Trace (topic=topic2, level=error, destination="log/topic2_trace.log")