trace 命令
trace 命令用于追踪某个客户端或 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 追踪 |
Tip
使用 trace 之前,需要将主日志等级(primary logger level) 设置成足够低的值。为提高系统运行性能,默认的主日志等级是 error。
trace start client <ClientId> <File> [<Level>]
开启 Client 追踪:
$ ./bin/emqx_ctl log primary-level debug
debug
$ ./bin/emqx_ctl trace start client clientid log/clientid_trace.log
trace client clientid successfully
$ ./bin/emqx_ctl trace start client clientid2 log/clientid2_trace.log error
trace client_id clientid2 successfully
trace stop client <ClientId>
关闭 Client 追踪:
$ ./bin/emqx_ctl trace stop client clientid
stop tracing client_id clientid successfully
trace start topic <Topic> <File> [<Level>]
开启 Topic 追踪:
$ ./bin/emqx_ctl log primary-level debug
debug
$ ./bin/emqx_ctl trace start topic topic log/topic_trace.log
trace topic topic successfully
$ ./bin/emqx_ctl trace start topic topic2 log/topic2_trace.log error
trace topic topic2 successfully
trace stop topic <Topic>
关闭 Topic 追踪:
$ ./bin/emqx_ctl trace topic topic off
stop tracing topic topic successfully
trace list
查询全部开启的追踪:
$ ./bin/emqx_ctl trace list
Trace(client_id=clientid2, level=error, destination="log/clientid2_trace.log")
Trace(topic=topic2, level=error, destination="log/topic2_trace.log")