log 命令

log 命令用于设置日志等级。访问 Documentation of logger 以获取详细信息

命令描述
log set-level <Level>设置主日志等级和所有 Handlers 日志等级
log primary-level查看主日志等级
log primary-lelvel <Level>设置主日志等级
log handlers list查看当前安装的所有 Handlers
log handlers start <HandlerId>启动某个已停止的 Handler
log handlers stop <HandlerId>停止某个 Handler
log handlers set-level <HandlerId> <Level>设置指定 Handler 的日志等级

日志的等级由低到高分别为:debug | info | notice | warning | error | critical | alert | emergency,日志等级越低,系统输出的日志数量越多,消耗的系统资源越大。为提高系统运行性能,默认的主日志等级是 error。

log set-level

设置主日志等级和所有 Handlers 日志等级:

  1. $ ./bin/emqx_ctl log set-level debug
  2. debug

log primary-level

查看主日志等级:

  1. $ ./bin/emqx_ctl log primary-level
  2. debug

log primary-level

设置主日志等级:

  1. $ ./bin/emqx_ctl log primary-level info
  2. info

log handlers list

查看当前安装的所有 Handlers:

  1. $ ./bin/emqx_ctl log handlers list
  2. LogHandler(id=ssl_handler, level=debug, destination=console, status=started)
  3. LogHandler(id=file, level=warning, destination=log/emqx.log, status=started)
  4. LogHandler(id=default, level=warning, destination=console, status=started)

log handlers start

启动 log handler 'default':

  1. $ ./bin/emqx_ctl log handlers start default
  2. log handler default started

log handlers stop

停止 log handler 'default':

  1. $ ./bin/emqx_ctl log handlers stop default
  2. log handler default stopped

log handlers set-level

设置指定 Handler 的日志等级:

  1. $ ./bin/emqx_ctl log handlers set-level emqx_logger_handler error
  2. error