When your Enterprise WeChat bot misbehaves, the first question is always: "What happened?" And the answer is always in the logs — if you know how to query them.
The problem isn't that logs don't exist. It's that they're too verbose, poorly structured, and painful to search. Let's fix that with a proper log query setup for your OpenClaw Enterprise WeChat bot on Tencent Cloud Lighthouse.
Your OpenClaw bot generates logs at multiple levels:
# Systemd journal — daemon-level events
journalctl -u clawdbot
# Application logs — message processing, API calls
/var/log/clawdbot/output.log
# Error logs — failures and exceptions
/var/log/clawdbot/error.log
# Access logs — webhook requests from Enterprise WeChat
/var/log/clawdbot/access.log
Each source answers different questions:
Here are the queries you'll use 90% of the time:
journalctl -u clawdbot --since "1 hour ago" -p err --no-pager
grep "user_id=wxuser_abc123" /var/log/clawdbot/output.log | tail -20
grep -i "timeout\|timed out" /var/log/clawdbot/error.log | tail -20
grep "$(date +%Y-%m-%d)" /var/log/clawdbot/output.log | grep -c "msg_processed"
grep "webhook.*fail\|delivery.*error" /var/log/clawdbot/output.log
Instead of remembering grep patterns, build a query script:
#!/bin/bash
# /opt/clawdbot/logquery.sh
# Usage: ./logquery.sh [command] [args]
case "$1" in
errors)
SINCE="${2:-1 hour ago}"
echo "=== Errors since $SINCE ==="
journalctl -u clawdbot --since "$SINCE" -p err --no-pager
;;
user)
USER_ID="$2"
echo "=== Activity for user $USER_ID ==="
grep "user_id=$USER_ID" /var/log/clawdbot/output.log | tail -${3:-20}
;;
stats)
echo "=== Today's Stats ==="
echo "Messages: $(grep "$(date +%Y-%m-%d)" /var/log/clawdbot/output.log | grep -c 'msg_processed')"
echo "Errors: $(grep "$(date +%Y-%m-%d)" /var/log/clawdbot/error.log | wc -l)"
echo "Unique users: $(grep "$(date +%Y-%m-%d)" /var/log/clawdbot/output.log | grep -oP 'user_id=\K[^ ]+' | sort -u | wc -l)"
;;
slow)
THRESHOLD="${2:-3000}"
echo "=== Responses slower than ${THRESHOLD}ms ==="
grep "response_time" /var/log/clawdbot/output.log | \
awk -F'response_time=' '{print $2}' | \
awk -v t="$THRESHOLD" '$1 > t {print}' | tail -20
;;
tail)
journalctl -u clawdbot -f --no-pager
;;
*)
echo "Usage: $0 {errors|user|stats|slow|tail} [args]"
echo " errors [since] - Show errors (default: last hour)"
echo " user [user_id] [n] - Show user activity (default: last 20)"
echo " stats - Show today's statistics"
echo " slow [ms] - Show slow responses (default: >3000ms)"
echo " tail - Follow live logs"
;;
esac
chmod +x /opt/clawdbot/logquery.sh
# Examples:
./logquery.sh errors "2 hours ago"
./logquery.sh user wxuser_abc123
./logquery.sh stats
./logquery.sh slow 5000
A proper log query setup needs a properly configured server. Tencent Cloud Lighthouse gives you the OpenClaw runtime with systemd logging already wired up.
Here's a power move: let admins query logs through the Enterprise WeChat bot:
# Add a log-query skill for admins only
skills:
log-query:
enabled: true
permission: admin_only
description: "Query bot logs via chat commands"
commands:
"/logs errors": "Show recent errors"
"/logs user [id]": "Show user activity"
"/logs stats": "Show daily statistics"
An admin types /logs errors in Enterprise WeChat, and the bot runs the query on the server and returns the results — no SSH required.
Don't let logs eat your disk:
# Check current log disk usage
du -sh /var/log/clawdbot/
# Set up automatic cleanup
cat > /etc/logrotate.d/clawdbot <<'EOF'
/var/log/clawdbot/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
copytruncate
}
EOF
Log queries are your first line of defense when something goes wrong. With a proper query toolkit, you go from "I have no idea what happened" to "I found the issue" in under a minute.
Build on the right foundation:
The best debugging tool is a well-structured log.