Learn to read, filter, and analyze OpenClaw logs to diagnose issues and optimize agent performance.
Overview
Effective logging and debugging are essential for diagnosing issues with your OpenClaw agent quickly. This article covers log configuration, the different log levels, output formats, log rotation, and practical debugging techniques that will save you hours of troubleshooting.
Log Levels
OpenClaw uses five standard log levels, ordered from most to least verbose:
Level
Description
When to Use
debug
Detailed internal state, API payloads, memory lookups
Deep troubleshooting
info
Normal operations: startup, shutdown, skill loading
Failures: API errors, skill crashes, connection drops
Always enabled
fatal
Unrecoverable errors that cause the agent to stop
Always enabled
Setting the Log Level
# Via CLI
openclaw config set logging.level debug
# Via environment variable
export OPENCLAW_LOG_LEVEL=debug
openclaw start
# In config.yaml
logging:
level: info
Tip: Use debug only during active troubleshooting. It generates significantly more output and can impact performance.
Log Output Destinations
Logs can be directed to multiple destinations simultaneously:
# Stream all logs
openclaw logs --follow
# Stream only errors
openclaw logs --follow --level error
# Stream with grep filter
openclaw logs --follow --grep "skill:weather"
Historical Logs
# Last 100 entries
openclaw logs --last 100
# Logs from the last hour
openclaw logs --since 1h
# Logs from a specific time range
openclaw logs --since "2024-01-15 09:00" --until "2024-01-15 10:00"
# Export logs to a file
openclaw logs --since 24h --output debug-session.log
logging:
file:
path: ~/.openclaw/logs/agent.log
max_size: 50MB # Rotate when file exceeds this size
max_files: 10 # Keep up to 10 rotated files
max_age: 30d # Delete files older than 30 days
compress: true # Gzip rotated files
Rotated files are named agent.log.1, agent.log.2, etc. With compress: true, they become agent.log.1.gz.
Module-Specific Logging
Enable debug logging for specific modules without flooding the log:
logging:
level: info # Default level
modules:
model: debug # Debug AI model interactions
skills: debug # Debug skill execution
memory: warn # Only warnings for memory
platform: info # Normal platform logging
# CLI shorthand
openclaw config set logging.modules.model debug
openclaw config set logging.modules.skills debug
This is extremely useful when you know which subsystem is causing problems.
Debugging Techniques
1. The Doctor Command
Always start here. It checks all components automatically:
Test configuration changes without affecting the live agent:
openclaw start --dry-run
This validates the config, checks connections, and reports what would happen — without actually starting.
3. Request Tracing
Trace a single request through the entire pipeline:
openclaw ask "What's the weather?" --trace
Trace output shows every step:
[TRACE] Input received: "What's the weather?"
[TRACE] Memory lookup: 3 relevant entries found (12ms)
[TRACE] Skill match: weather-forecast (confidence: 0.94)
[TRACE] Skill execution: weather-forecast (started)
[TRACE] API call: wttr.in/Berlin (200 OK, 89ms)
[TRACE] Skill execution: weather-forecast (completed, 102ms)
[TRACE] Model request: gpt-4o (2140 tokens)
[TRACE] Model response: 380 tokens (1.2s, $0.0031)
[TRACE] Total pipeline: 1.4s
4. Skill Debugging
Run a specific skill in isolation:
# Test a skill directly
openclaw skills test weather-forecast --input "Weather in Berlin"
# Run with debug output
openclaw skills test weather-forecast --input "Weather in Berlin" --debug