Skip to content

OpenClaw 调试技巧

快速定位和解决问题的方法。


🔍 问题诊断流程

1. 检查状态

bash
# 查看整体状态
openclaw status

# 查看网关状态
openclaw gateway status

# 查看通道状态
openclaw channels list

2. 查看日志

bash
# 实时日志
openclaw logs --follow

# 最近 50 条
openclaw logs --tail 50

# 按级别过滤
openclaw logs --level error

3. 测试连接

bash
# 测试网关
openclaw gateway probe

# 测试模型
openclaw models test

# 测试通道
openclaw channels test feishu

🛠️ 常见问题排查

问题 1:网关无法启动

症状

bash
openclaw gateway start
# 无响应或报错

排查步骤

bash
# 1. 检查端口占用
netstat -tlnp | grep 18789

# 2. 查看配置文件
cat ~/.openclaw/openclaw.json

# 3. 查看详细日志
openclaw logs --level debug

# 4. 重置配置
openclaw configure

解决方案

bash
# 如果端口被占用
kill -9 <PID>

# 重新配置
openclaw configure

# 启动网关
openclaw gateway start

问题 2:消息无法发送

症状

  • 消息显示发送失败
  • 对方收不到消息

排查步骤

bash
# 1. 检查通道配置
openclaw channels info feishu

# 2. 测试发送
openclaw message send --target user:xxx "测试消息"

# 3. 查看发送日志
openclaw logs --grep message

常见原因

  1. API Key 过期
  2. 权限不足
  3. 网络问题

解决方案

bash
# 更新配置
openclaw configure

# 检查网络
curl -I https://open.feishu.cn

# 重启网关
openclaw gateway restart

问题 3:AI 不回复

症状

  • 收到消息但 AI 不回复
  • 回复延迟很长

排查步骤

bash
# 1. 检查模型配置
openclaw models list

# 2. 测试模型
openclaw models test qwen3.5-plus

# 3. 查看会话状态
openclaw sessions list

# 4. 检查资源使用
openclaw status

解决方案

bash
# 切换模型
openclaw models use qwen3.5-plus

# 清理会话
openclaw sessions clean

# 重启服务
openclaw gateway restart

问题 4:技能不工作

症状

  • 技能命令无响应
  • 技能执行报错

排查步骤

bash
# 1. 列出已安装技能
openclaw skills list

# 2. 检查技能状态
openclaw skills info <skill-name>

# 3. 测试技能
openclaw skills test <skill-name>

# 4. 查看技能日志
openclaw logs --grep skill

解决方案

bash
# 重新安装技能
openclaw skills uninstall <skill-name>
openclaw skills install <skill-name>

# 更新技能
openclaw skills update <skill-name>

🔧 调试工具

1. 交互式调试

bash
# 进入交互模式
openclaw shell

# 执行命令
> gateway status
> sessions list
> exit

2. 配置检查

bash
# 验证配置
openclaw config validate

# 查看配置
openclaw config get channels.feishu

# 导出配置
openclaw config export > config.json

3. 性能分析

bash
# 查看资源使用
openclaw status --deep

# 分析会话
openclaw sessions analyze

# 查看缓存
openclaw cache stats

📊 日志分析

日志级别

ERROR  - 错误,需要立即处理
WARN   - 警告,可能有问题
INFO   - 信息,正常运行
DEBUG  - 调试,详细信息

查看特定日志

bash
# 错误日志
openclaw logs --level error --since 1h

# 特定模块
openclaw logs --module feishu

# 特定会话
openclaw logs --session <session-id>

日志导出

bash
# 导出日志
openclaw logs --export > logs.txt

# 分析日志
cat logs.txt | grep ERROR

🐛 高级调试

1. 启用调试模式

bash
# 设置调试级别
export OPENCLAW_DEBUG=1

# 启动网关
openclaw gateway start

2. 网络抓包

bash
# 使用 tcpdump
sudo tcpdump -i any port 18789 -w openclaw.pcap

# 使用 Wireshark 分析
wireshark openclaw.pcap

3. 性能分析

bash
# 使用 node --inspect
node --inspect $(which openclaw) gateway start

# 连接 Chrome DevTools
# 访问 chrome://inspect

📋 调试检查清单

基础检查

  • [ ] 服务是否运行
  • [ ] 配置是否正确
  • [ ] 网络是否通畅
  • [ ] 权限是否足够

进阶检查

  • [ ] 日志是否有错误
  • [ ] 资源是否充足
  • [ ] 缓存是否过期
  • [ ] 依赖是否正常

深度检查

  • [ ] 代码逻辑是否正确
  • [ ] 数据流是否通畅
  • [ ] 性能是否达标
  • [ ] 安全是否合规

🆘 获取帮助

官方文档

社区支持

提交问题

bash
# 收集诊断信息
openclaw doctor

# 提交问题报告
openclaw doctor --report

提示

遇到问题先查日志,80% 的问题都能在日志中找到线索!

🟢🐉 泡泡龙

Released under the MIT License.