#openclaw log file rotation

1 messages · Page 1 of 1 (latest)

ashen kettle
#

@oblique apex is there a log file rotation feature in openclaw?

My ~/.openclaw/logs/gateway.log is 3.9 MB with entires almost a month old.

jovial sailBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

oblique apexBOT
#

OpenClaw has rolling “real” gateway logs, but ~/.openclaw/logs/gateway.log is not that.

What’s going on

  • Gateway file logs (the ones OpenClaw tails in the UI/CLI) default to a daily file:
  • ~/.openclaw/logs/gateway.log (and gateway.err.log) are daemon/supervisor stdout/stderr logs (most commonly macOS launchd). Those don’t get rotated by OpenClaw, and launchd also doesn’t rotate them automatically.

So seeing “entries almost a month old” in gateway.log usually just means “this daemon has been running for a month, and the file contains old lines near the top”.

What to do

  • For day-to-day debugging, use:
    openclaw logs --follow
    
  • If you want ~/.openclaw/logs/gateway.log to stop growing, you currently need OS-level rotation (or just truncate it occasionally). The low-drama option is to truncate (ideally after stopping the service):
#
  openclaw gateway stop
  : > ~/.openclaw/logs/gateway.log
  : > ~/.openclaw/logs/gateway.err.log
  openclaw gateway start

If you tell me your OS (macOS vs Linux) + whether you installed the gateway as a service, I can point you at the right built-in rotation mechanism (systemd/journald on Linux vs newsyslog/launchd on macOS).

ashen kettle
#

I am on macos and want to understand by the logs are not rotated when running openclaw as a daemon. I installed the daemon with openclaw gateway install

oblique apexBOT
#

On macOS, when you run the Gateway as a LaunchAgent (openclaw gateway install), there are two different “log files” involved:

  1. OpenClaw’s structured gateway log (rotates daily by filename)
    This is what openclaw logs --follow and the Control UI “Logs” tab tail.
    Default is:
  • /tmp/openclaw/openclaw-YYYY-MM-DD.log (new file each day)

Docs: https://docs.openclaw.ai/logging

  1. launchd stdout/stderr capture (NOT rotated by OpenClaw)
    This is what you’re looking at:
  • ~/.openclaw/logs/gateway.log
  • ~/.openclaw/logs/gateway.err.log

Those paths come from the LaunchAgent plist’s StandardOutPath / StandardErrorPath. launchd does not rotate these, and OpenClaw currently doesn’t add a rotation layer for them either — so they can just grow slowly over time.

#

What you can do

  • Recommended: use openclaw logs --follow for real debugging, and treat ~/.openclaw/logs/gateway*.log as “service wrapper noise”.
  • Reduce growth: lower console verbosity in ~/.openclaw/openclaw.json:
    {
      logging: {
        consoleLevel: "warn"
      }
    }
    
  • If you want actual rotation for ~/.openclaw/logs/gateway.log: use macOS’ built-in newsyslog (OS-level log rotation). That’s outside OpenClaw, but it’s the “native” way on macOS.

If you want, paste the output of openclaw gateway status (it prints the service log paths), and I’ll give you a newsyslog stanza tailored to your exact paths.

ashen kettle
#

openclaw gateway status

🦞 OpenClaw 2026.2.24 (df9a474)
Give me a workspace and I'll give you fewer tabs, fewer toggles, and more oxygen.

│
â—‡
Service: LaunchAgent (loaded)
File logs: /tmp/openclaw/openclaw-2026-02-25.log
Command: /opt/homebrew/Cellar/node@22/22.22.0_1/bin/node /Users/clawd/.npm-global/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Service file: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
Service env: OPENCLAW_GATEWAY_PORT=18789

Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: running (pid 94955, state active)
RPC probe: ok

Listening: 127.0.0.1:18789
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting

oblique apexBOT
#

On macOS the confusing bit is that ~/.openclaw/logs/gateway.log is not OpenClaw’s “main” log file — it’s just the launchd stdout/stderr capture from the daemon plist (StandardOutPath / StandardErrorPath). launchd doesn’t rotate those, and OpenClaw currently doesn’t add rotation on top, so they’ll happily accumulate.

In your openclaw gateway status you can see the real gateway file log:

  • File logs: /tmp/openclaw/openclaw-2026-02-25.log

Those are OpenClaw’s structured logs (what openclaw logs --follow and the Control UI tail). They’re daily by filename.

Why your ~/.openclaw/logs/gateway.log doesn’t rotate

openclaw gateway install creates a LaunchAgent plist (~/Library/LaunchAgents/ai.openclaw.gateway.plist) that points stdout/stderr at stable files under $OPENCLAW_STATE_DIR/logs/ (default ~/.openclaw/logs/). macOS doesn’t rotate those files automatically.

Options

  1. Do nothing: 3.9 MB/month is honestly tiny.
  2. Reduce what goes into that file (since it’s “console logs”): set a higher console threshold in ~/.openclaw/openclaw.json, e.g.
{
#
  logging: {
    consoleLevel: "warn",
  },
}
  1. Rotate it the macOS way: use newsyslog (OS log rotation) for:
  • ~/.openclaw/logs/gateway.log
  • ~/.openclaw/logs/gateway.err.log

Create /etc/newsyslog.d/openclaw.conf (needs sudo) with something like (replace <you>):

# logfilename                               owner:group  mode  count  size(KB)  when  flags
/Users/<you>/.openclaw/logs/gateway.log     <you>:staff   644   10     5120      *     J
/Users/<you>/.openclaw/logs/gateway.err.log <you>:staff   644   10     5120      *     J

That keeps 10 archives and rotates when the file exceeds ~5 MB (and J compresses archives).

ashen kettle
#

Do other launch service not have such feature in their implementation, or is it generally left to the OS?