openclaw logs
查看和管理 OpenClaw 运行日志。
概要
bash
openclaw logs [子命令] [选项]描述
openclaw logs 命令用于查看 OpenClaw 运行过程中产生的各类日志信息,包括系统日志、Agent 日志和通道日志。支持实时跟踪、按级别过滤、按时间范围筛选等功能,方便快速排查问题。
子命令
| 子命令 | 说明 |
|---|---|
show | 显示日志(默认) |
clear | 清除历史日志 |
export | 导出日志到文件 |
选项
| 选项 | 缩写 | 说明 | 默认值 |
|---|---|---|---|
--follow | -f | 实时跟踪日志输出 | false |
--level <level> | -l | 过滤日志级别:debug、info、warn、error | info |
--since <time> | -s | 显示指定时间之后的日志,如 1h、30m、2d | - |
--until <time> | -u | 显示指定时间之前的日志 | - |
--lines <n> | -n | 显示最近 n 条日志 | 100 |
--source <name> | 按来源过滤:system、agent、channel | 全部 | |
--format <type> | 输出格式:text、json | text |
日志格式
默认文本格式如下:
[2026-03-05 10:23:45] [INFO] [agent] 收到来自 WhatsApp 的消息
[2026-03-05 10:23:46] [DEBUG] [system] 调度模型:deepseek-chat
[2026-03-05 10:23:48] [INFO] [agent] 回复已发送示例
bash
# 查看最近日志
openclaw logs
# 实时跟踪日志
openclaw logs --follow
# 只看错误日志
openclaw logs --level error
# 查看最近 1 小时的调试日志
openclaw logs --level debug --since "1h"
# 只看 Agent 来源的日志,最近 50 条
openclaw logs --source agent --lines 50
# 导出日志到文件
openclaw logs export --since "1d" --format json > logs.json
# 清除 7 天前的日志
openclaw logs clear --before "7d"相关命令
openclaw status- 查看系统状态openclaw system- 查看系统信息openclaw sessions- 会话管理
