src/hooks/bundled/command-logger/HOOK.md
Logs all command events (/new, /reset, /stop, etc.) to a centralized audit log file for debugging and monitoring purposes.
Every time you issue a command to the agent:
~/.openclaw/logs/commands.logLog entries are written in JSONL (JSON Lines) format:
{"timestamp":"2026-01-16T14:30:00.000Z","action":"new","sessionKey":"agent:main:main","senderId":"+1234567890","source":"telegram"}
{"timestamp":"2026-01-16T15:45:22.000Z","action":"stop","sessionKey":"agent:main:main","senderId":"[email protected]","source":"whatsapp"}
~/.openclaw/logs/commands.log
No requirements - this hook works out of the box on all platforms.
No configuration needed. The hook automatically:
To disable this hook:
openclaw hooks disable command-logger
Or via config:
{
"hooks": {
"internal": {
"entries": {
"command-logger": { "enabled": false }
}
}
}
}
The hook does not automatically rotate logs. To manage log size, you can:
Manual rotation:
mv ~/.openclaw/logs/commands.log ~/.openclaw/logs/commands.log.old
Use logrotate (Linux):
Create /etc/logrotate.d/openclaw:
/home/username/.openclaw/logs/commands.log {
weekly
rotate 4
compress
missingok
notifempty
}
View recent commands:
tail -n 20 ~/.openclaw/logs/commands.log
Pretty-print with jq:
cat ~/.openclaw/logs/commands.log | jq .
Filter by action:
grep '"action":"new"' ~/.openclaw/logs/commands.log | jq .