Home Tutorials Categories Skills About
ZH EN JA KO
Operations

OpenClaw Log Analysis and Troubleshooting Techniques

· 18 min read

Introduction

When OpenClaw exhibits abnormal behavior — messages not being replied to, delayed responses, channel disconnections — logs are your most important troubleshooting tool. This article systematically explains how to read OpenClaw's log format, identify key fields, and master techniques for quickly locating common error patterns.

1. Log Format Details

1.1 Standard Text Format

OpenClaw uses a structured text format for log output by default. Each line contains the following fields:

[2026-03-14 09:15:32.456] [INFO] [gateway] Message received (WhatsApp) msgId=msg_a1b2c3

Field descriptions:

Field Example Description
Timestamp 2026-03-14 09:15:32.456 Event time with millisecond precision
Level INFO Log level: DEBUG/INFO/WARN/ERROR
Component gateway Internal module that produced the log
Message body Message received (WhatsApp) Event description
Additional fields msgId=msg_a1b2c3 Contextual information as key-value pairs

1.2 JSON Format

When log.format: "json" is configured, logs are output in JSON format, making programmatic analysis easier:

{
  "timestamp": "2026-03-14T09:15:32.456Z",
  "level": "info",
  "component": "gateway",
  "message": "Message received",
  "meta": {
    "channel": "whatsapp",
    "msgId": "msg_a1b2c3",
    "from": "+8613800138000"
  }
}

1.3 Core Component Identifiers

Common components found in OpenClaw logs include:

Component Responsibility
gateway Gateway core, responsible for message routing
model AI model invocation layer
channel:whatsapp WhatsApp channel adapter
channel:telegram Telegram channel adapter
channel:discord Discord channel adapter
skill Skill execution engine
memory Conversation memory management
config Configuration loading and validation
health Health check module

2. Key Log Field Interpretation

2.1 Message Lifecycle Tracking

Each message is assigned a unique traceId within OpenClaw, which persists throughout the entire processing chain. You can use the traceId to trace a message's complete journey from reception to reply:

# Filter by traceId for the complete chain
openclaw logs --since 1h | grep "traceId=trace_x7y8z9"

Example output:

[09:15:32.456] [INFO] [gateway] Message received traceId=trace_x7y8z9 channel=whatsapp
[09:15:32.480] [INFO] [memory] Loading conversation history traceId=trace_x7y8z9 historyCount=12
[09:15:32.510] [INFO] [model] Sending API request traceId=trace_x7y8z9 model=claude-3.5-sonnet
[09:15:34.230] [INFO] [model] Received API response traceId=trace_x7y8z9 latency=1720ms tokens=285
[09:15:34.250] [INFO] [gateway] Sending reply traceId=trace_x7y8z9 channel=whatsapp

2.2 Performance-Related Fields

In model invocation logs, the following fields are critical for performance analysis:

  • latency: Time from sending the request to receiving the complete response (milliseconds)
  • inputTokens: Number of input tokens, reflecting context length
  • outputTokens: Number of output tokens
  • cost: Estimated cost of this call (USD)
  • retryCount: Number of retries; a non-zero value indicates the first request failed

3. Common Error Patterns and Diagnosis Methods

3.1 Model API Authentication Failure

[ERROR] [model] API call failed: 401 Unauthorized provider=claude error="Invalid API key"

Diagnosis method:

# Check API Key configuration
openclaw config get model.apiKey
# Confirm the key starts with the correct prefix (e.g., sk-ant-)

# Test API Key validity
curl -H "x-api-key: YOUR_KEY" https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -d '{"model":"claude-3-5-sonnet-20241022","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'

3.2 Rate Limiting

[WARN] [model] API rate limited provider=openai statusCode=429 retryAfter=30s
[WARN] [model] Queued and waiting queueLength=5 estimatedWait=45s

Diagnosis method:

# Count 429 errors in the last hour
openclaw logs --since 1h --level warn | grep "429" | wc -l

# Check request frequency
openclaw logs --since 1h --component model | grep "Sending API request" | wc -l

Resolution: Reduce concurrent requests, enable request queuing, or switch to an API plan with higher quotas.

3.3 Channel Disconnection

[ERROR] [channel:whatsapp] WebSocket connection lost code=1006 reason="Connection lost"
[INFO] [channel:whatsapp] Attempting reconnection attempt=1/5
[INFO] [channel:whatsapp] Reconnection successful downtime=8s

Diagnosis method:

# View disconnection history for a specific channel
openclaw logs --since 24h --component channel:whatsapp --level error

# Count disconnection frequency
openclaw logs --since 7d | grep "connection lost" | awk '{print $1}' | sort | uniq -c

If disconnections occur frequently, check network stability and server firewall settings.

3.4 Memory Overflow Warning

[WARN] [gateway] High memory usage heapUsed=480MB heapTotal=512MB percentage=94%
[ERROR] [gateway] OOM: Approaching memory limit, clearing cache

Diagnosis method:

# View memory trend
openclaw logs --since 6h | grep "heapUsed"

# Check for memory leaks (memory continuously growing without release)
openclaw logs --since 24h | grep "heapUsed" | awk -F'heapUsed=' '{print $2}' | head -20

3.5 Skill Execution Failure

[ERROR] [skill] Skill execution timeout skillName=weather timeout=10000ms
[ERROR] [skill] Skill runtime error skillName=rss error="ECONNREFUSED 127.0.0.1:3000"

Diagnosis method:

# View error records for a specific skill
openclaw logs --since 24h --component skill | grep "weather"

# Use openclaw doctor to check skill status
openclaw doctor --check skills

4. Efficient Log Analysis Techniques

4.1 Quickly Locating Errors

# View recent error summary
openclaw logs --since 1h --level error

# Count errors by component
openclaw logs --since 24h --level error --format json | jq '.component' | sort | uniq -c | sort -rn

4.2 Response Latency Analysis

# Find requests with response time exceeding 5 seconds
openclaw logs --since 1h --component model | grep "latency=" | awk -F'latency=' '{
  split($2, a, "ms"); if(a[1] > 5000) print $0
}'

4.3 Automatic Diagnostics with openclaw doctor

The openclaw doctor command automatically scans recent logs and identifies common issues:

openclaw doctor

# Example output
# ✓ Service status: Running (uptime: 3d 12h)
# ✓ Gateway port: 18789 accessible
# ⚠ 3 API 429 errors in the last hour
# ✓ All channel connections normal
# ⚠ Memory usage 78%, monitor recommended
# ✓ Disk space sufficient

4.4 Exporting Logs for External Analysis

# Export last 24 hours of logs in JSON format
openclaw logs --since 24h --format json > /tmp/openclaw-logs-export.json

# Use jq for complex queries
cat /tmp/openclaw-logs-export.json | jq 'select(.level == "error") | {time: .timestamp, msg: .message, component: .component}'

5. Log Analysis Best Practices

  1. Establish baselines: Record key metrics (average latency, error rate, memory usage) when the system is running normally, so you can compare when issues arise
  2. Layer your investigation: Start with ERROR level to narrow the scope, then switch to DEBUG level for details
  3. Leverage traceId: Trace the complete chain of a single request — don't get overwhelmed by massive log volumes
  4. Regular review: Spend a few minutes each week browsing WARN level logs to catch potential issues before they escalate
  5. Automated alerting: Integrate with monitoring systems to set up automatic alerts for critical error patterns, reducing manual inspection burden

By mastering these log analysis techniques, you'll be able to locate most OpenClaw operational issues within minutes, significantly reducing recovery time.

OpenClaw is a free, open-source personal AI assistant that supports WhatsApp, Telegram, Discord, and many more platforms