前提:开启远程日志

远端配置文件中必须开启以下三项。缺一项都是在盲人摸象

# openclaw.json 或对应配置文件中必须存在
debug: true
logging-to-file: true
request-log: true

OpenClaw 日志

命令行查看

# 最近 200 条日志,纯文本,本地时间
openclaw logs --limit 200 --plain --local-time

# 更多日志
openclaw logs --limit 500 --plain --local-time

直接读日志文件

# commands.log 记录所有命令执行
tail -200 ~/.openclaw/logs/commands.log

# 实时跟踪
tail -f ~/.openclaw/logs/commands.log

CLIProxyAPI 日志

systemd journal

# 实时跟踪 CLIProxyAPI 输出
journalctl --user -u cliproxyapi -f

# 最近 200 行
journalctl --user -u cliproxyapi -n 200 --no-pager

 # 按时间范围
journalctl --user -u cliproxyapi --since "2026-03-01" --until "2026-03-02"

错误日志文件

# CLIProxyAPI 的 error log
ls /root/cliproxyapi/logs/
tail -100 /root/cliproxyapi/logs/error.log

实时监控:watch_cpa_logs.sh

自研脚本,通过管理 API 轮询实现 CLIProxyAPI 实时日志监控。支持 checkpoint 断点续看去重,不会重复输出已看过的日志。

# 启动实时监控
./watch_cpa_logs.sh

# 带 checkpoint 续看(上次看到哪,接着看)
./watch_cpa_logs.sh --resume

日志排查优先级