Phase 2 / Ep 12: Logging System —— logs, sessions, Practical Troubleshooting
🎯 Learning Objective: Master log management and troubleshooting methods.
1. Layered Logging Architecture
graph TB
subgraph Logs["📋 Logging System"]
GWLog["🌐 Gateway Logs\nRouting · Authentication · Plugin Pipeline\n~/.openclaw/logs/gateway.log"]
AgentLog["🤖 Agent Session Logs\nComplete Conversation Records\nagents/xxx/sessions/*.jsonl"]
LLMLog["🧪 LLM Call Logs\nToken Usage · Latency · Errors\nEmbedded in session logs"]
ToolLog["🔧 Tool Execution Logs\nShell Output · File Operations\nEmbedded in session logs"]
end2. Core Commands
# View Gateway logs (last 50 lines)
openclaw logs
# Real-time log tracking
openclaw logs --follow
# Filter by level
openclaw logs --level error
openclaw logs --level warn
# Filter by time range
openclaw logs --since "2h" # Last 2 hours
openclaw logs --since "1d" # Last 1 day
# Session Management
openclaw sessions list # List all sessions
openclaw sessions show <id> # View a specific session
openclaw sessions clear # Clear current session
3. Common Troubleshooting
| Symptom | Possible Cause | Troubleshooting Command |
|---|---|---|
| Agent not responding | Gateway not started | openclaw status |
| Slow response | LLM API rate limiting | openclaw logs --level warn |
| Tool call failed | Insufficient permissions | openclaw logs --level error |
| Telegram unresponsive | Bot Token expired | openclaw channels status |
| 429 Too Many Requests | API quota exhausted | openclaw logs --follow |
4. CLI vs Telegram Comparison
| Operation | CLI Command | Telegram |
|---|---|---|
| View logs | openclaw logs |
/logs |
| Real-time tracking | openclaw logs --follow |
N/A |
| Error filtering | openclaw logs --level error |
/logs errors |
| Session list | openclaw sessions list |
/sessions |
| Clear session | openclaw sessions clear |
/clear |
Next Episode Preview: Phase 3 begins! In Ep 13, we delve into OpenClaw's most crucial security mechanism—the Permission Model. From basic to full, understand the capability boundaries of each level.