OpenClawSkills
GitHub
Gateway / 运用 • TutorialHeader.readTime

日志记录

Logging surfaces, file logs, WS log styles, and console formatting

For a user-facing overview (CLI + Control UI + config), see ''/logging''.

OpenClaw 在是 2 次的日志"表面"有:

- Console output (what you see in the terminal / Debug UI).

- File logs (JSON lines) written by the gateway logger.

Tutorial.step

File-based logger

- Default rolling log file is under ''/tmp/openclaw/'' (one file per day): ''openclaw-YYYY-MM-DD.log''

- 日期是网关主机的本地时区使用执行。

- The log file path and level can be configured via ''~/.openclaw/openclaw.json'':

- ''logging.file''

- ''logging.level''

文件格式是每行一个 JSON 对象。

The Control UI Logs tab tails this file via the gateway (''logs.tail'').

CLI 也可以做同样的操作:

Bash
openclaw logs --follow

详情和日志级别

- ''文件日志''是 ''logging.level'' 在仅控制被。

- ''--verbose'' only affects ''console verbosity'' (and WS log style); it does ''not''

raise the file log level.

''trace''.

To capture verbose-only details in file logs, set ''logging.level'' to ''debug'' or

Tutorial.step

Console capture

文件格式是每行一个 JSON 对象。

The Control UI Logs tab tails this file via the gateway (''logs.tail'').

您可以通过以下方式独立调整控制台详细程度:

- ''logging.consoleLevel''(默认 ''info'')

- ''logging.consoleStyle'' (''pretty'' | ''compact'' | ''json'')

Tutorial.step

Console capture

The CLI captures ''console.log/info/warn/error/debug/trace'' and writes them to file logs,

while still printing to stdout/stderr.

- ''logging.consoleLevel'' (default ''info'')

- ''logging.consoleStyle'' (''pretty'' | ''compact'' | ''json'')

- Use raw regex strings (auto ''gi''), or ''/pattern/flags'' if you need custom flags.

- Matches are masked by keeping the first 6 + last 4 chars (length >= 18), otherwise ''***''.

- Defaults cover common key assignments, CLI flags, JSON fields, bearer headers, PEM blocks, and popular token prefixes.

Tutorial.step

网关 WebSocket 日志

Verbose tool summaries (e.g. ''🛠️ Exec: ...'') can mask sensitive tokens before they hit the console stream. This is ''tools-only'' and does not alter file logs.

- ''Normal mode (no ''--verbose'')'': only "interesting" RPC results are printed:

- ''logging.redactSensitive'': ''off'' | ''tools'' (default: ''tools'')

- ''logging.redactPatterns'': array of regex strings (overrides defaults)

- Use raw regex strings (auto ''gi''), or ''/pattern/flags'' if you need custom flags.

- ''Verbose mode (''--verbose'')'': prints all WS request/response traffic.

#

Tutorial.step

WS 日志样式

The gateway prints WebSocket protocol logs in two modes:

- ''--ws-log auto'' (default): normal mode is optimized; verbose mode uses compact output

- ''--ws-log compact'': compact output (paired request/response) when verbose

- ''--ws-log full'': full per-frame output when verbose

- ''--compact'':''--ws-log compact'' 的别名

例:

Bash
openclaw gateway


openclaw gateway --verbose --ws-log compact


openclaw gateway --verbose --ws-log full
Tutorial.step

Console formatting (subsystem logging)

控制台格式化器是TTY 感知的,并打印一致的前缀行。

子系统日志器保持输出分组且易于扫描。

动作:

- 每个行在是''子系统前缀''有(示示示例: ''[gateway]''、''[canvas]''、''[tailscale]'')

- 子系统颜色(子系统每个安定)+ 级别的色付可

- ''Color when output is a TTY or the environment looks like a rich terminal'' (''TERM''/''COLORTERM''/''TERM_PROGRAM''), respects ''NO_COLOR''

- ''Shortened subsystem prefixes'': drops leading ''gateway/'' + ''channels/'', keeps last 2 segments (e.g. ''whatsapp/outbound'')

ReferenceGatewayLoggingPage.step06.item5

- ''''logRaw()'''' for QR/UX output (no prefix, no formatting)

- ''Console styles'' (e.g. ''pretty | compact | json'')

- ''Console log level'' separate from file log level (file keeps full detail when ''logging.level'' is set to ''debug''/''trace'')

- ''WhatsApp message bodies'' are logged at ''debug'' (use ''--verbose'' to see them)

这可以保持现有文件日志的稳定性,同时使交互式输出可扫描。