OpenClaw Monitoring & Logging
OpenClaw can run shell commands, access files, and call external APIs. Monitoring and logging help you detect misuse, credential abuse, prompt injection attempts, and gateway or skill issues. This guide covers enabling audit logs, log rotation, alert rules, and anomaly detection so you can spot security events early.
Why Monitoring Matters for OpenClaw
Security researchers (including Cisco, CrowdStrike, and Snyk) have highlighted risks around the OpenClaw gateway, the ClawHub skills marketplace, and prompt injection. Without logs and alerts, you may not notice:
- Failed or repeated authentication attempts (gateway or channel)
- Unusual API usage or spending spikes (LLM or third-party APIs)
- Unexpected tool or skill use (e.g. shell, file access, or network calls you did not trigger)
- Gateway crashes, RPC errors, or channel disconnections
- Credential leaks or suspicious activity from installed skills
Enabling audit logs, log rotation, and alerting is part of defense in depth-along with network isolation, credential management, and hardening.
1. Enable Audit and Application Logs
OpenClaw writes application logs by default. Where they are stored depends on your install (e.g. data directory or systemd journal). Use the CLI to view and follow logs:
# View last 50 lines
openclaw logs --tail 50
# Follow logs in real time
openclaw logs --follow
If your deployment supports audit logging (security-relevant events such as auth failures, tool invocations, or config changes), enable it in your OpenClaw configuration according to the official documentation. Audit logs should be written to a separate stream or file so they can be retained and reviewed without mixing with high-volume application logs.
What to log (when configurable):
- Gateway start/stop and connection events
- Channel connections and disconnections
- Authentication failures or token errors
- Tool or skill invocations (especially shell, file, or network)
- Config or agent changes (if supported)
Avoid logging full message bodies or API keys; log enough context (e.g. channel, user id, tool name, timestamp) for investigation. For more on keeping secrets out of logs, see Credential Management.
2. Log Rotation Setup
Without rotation, log files can fill disk and make it harder to find recent events. Prefer your platform’s standard mechanism:
- Linux (systemd): If OpenClaw logs to the journal, use
journaldsettings (e.g.SystemMaxUse=,MaxRetentionSec=) to limit size and retention. See your distro’s systemd documentation. - Linux (file-based logs): Use logrotate. Create a config file (e.g.
/etc/logrotate.d/openclaw) to rotate OpenClaw log files daily or when they reach a size limit, keep a limited number of archives, and optionally compress old logs. - Docker: Configure the Docker logging driver (e.g.
json-filewithmax-sizeandmax-file) so container logs don’t grow unbounded. See Docker Hardening for more.
After changing rotation, verify that new log files are created and old ones are pruned so you retain enough history for security review (e.g. 7–30 days depending on policy).
3. Alert Rules Configuration
Set up alerts for critical security and operational events so you can react quickly. What to alert on:
| Event | Why |
|---|---|
| Repeated authentication or gateway token failures | Possible brute force or token leak |
| Gateway down or unreachable | Service availability; run openclaw doctor and check Gateway Issues |
| Unusual API usage or billing spike | Abuse or misconfiguration; pair with API spending limits |
| Unexpected tool use (e.g. shell, file write, network) | Prompt injection or malicious skill |
| High error rate in logs (RPC, channel, model errors) | Config or connectivity issues |
You can implement alerts by:
- Parsing log output with a log shipper (e.g. Fluentd, Filebeat) and sending to a SIEM or alerting stack (e.g. Grafana Loki + Alertmanager, Elasticsearch, Datadog).
- Using a cron job or systemd timer that runs
openclaw statusoropenclaw doctorand notifies you if the process is down or unhealthy. - Monitoring the host (CPU, memory, disk) and the OpenClaw process; alert on restarts or resource exhaustion.
Keep alert rules tuned to avoid noise; start with a small set of critical events and expand as needed.
4. Anomaly Detection
Anomaly detection helps spot behavior that doesn’t match normal use. As recommended in the Security Best Practices maintenance schedule, a daily glance at logs (or automated anomaly checks) is a good habit.
Signs to watch for:
- Messages or tool runs at odd hours or from unexpected channels
- Spikes in LLM or API calls compared to your baseline
- New or rarely used skills suddenly invoked
- Errors or stack traces that suggest credential or permission issues
- Log entries that mention sensitive paths, keys, or external IPs you don’t recognize
For high-stakes or enterprise deployments, consider feeding logs into a SIEM or security analytics platform and defining baselines (e.g. requests per hour, tools used per day) so you can alert on deviations. Combine with Skills Security (audit and pin skills) and Known Vulnerabilities to stay aware of reported issues.
Quick Reference: Commands and Health Checks
Use these OpenClaw CLI commands as part of monitoring and diagnostics:
# Service status
openclaw status
# Run health/diagnostic checks
openclaw doctor
# Optional: run with --fix for repairable issues (use with care)
openclaw doctor --fix
# View recent logs
openclaw logs --tail 50
# Follow logs live
openclaw logs --follow
# Security audit of installed skills (if available)
openclaw security audit
# Validate configuration
openclaw config validate
If the gateway is unreachable or you see RPC/probe errors, see Gateway Issues and Troubleshooting.
Common Issues & Solutions
| Issue | Cause | Solution |
|---|---|---|
| Logs not appearing or empty | Wrong path, permissions, or logging disabled | Check OpenClaw config and data directory; ensure process has write access. See Official Docs for log location. |
| Log files filling disk | No rotation or retention | Enable log rotation (logrotate or journald limits). |
| Too many alerts or false positives | Alert rules too sensitive | Tune thresholds; start with critical events only (auth failures, gateway down, large API spike). |
| Gateway down or RPC errors | Process crash, port conflict, or token mismatch | Run openclaw doctor; check Gateway Issues and Network Isolation (bind to localhost). |
Need more help? See the full Troubleshooting Guide.
Related Security Pages
🛡️ Hardening
🔐 Access & Skills
📋 Checklist & Docs
Next Steps
After configuring monitoring and logging:
- Complete the Security Checklist (logging and audit logging item)
- Set API spending limits and pair them with usage monitoring
- Review Skills Security and run
openclaw security auditregularly - Read the Regular Maintenance Schedule (daily logs, weekly updates, monthly key rotation and skills audit)