openclaw - ✅(Solved) Fix Log rotation: implement proper rotation instead of suppression at 500MB [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58583Fetched 2026-04-08 02:00:37
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Fix Action

Workaround

Manual truncation:

truncate -s 0 /tmp/openclaw/openclaw-2026-03-31.log

PR fix notes

PR #58621: add support for size based log file rolling update

Description (problem / solution / changelog)

Summary

  • Problem: This PR is an attempt for fixing the problem described in https://github.com/openclaw/openclaw/issues/58583
  • Why it matters: Improving debug experience
  • What changed: An ability to rotate the files instead of failing silently
  • What did NOT change (scope boundary): Any core functionality

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write N/A. If the cause is unclear, write Unknown.

  • Root cause:
  • Missing detection / guardrail:
  • Prior context (git blame, prior PR, issue, or refactor if known):
  • Why this regressed now:
  • If unknown, what was ruled out:

Regression Test Plan (if applicable)

For bug fixes or regressions, name the smallest reliable test coverage that should have caught this. Otherwise write N/A.

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
  • Scenario the test should lock in:
  • Why this is the smallest reliable guardrail:
  • Existing test that already covers this (if any):
  • If no new test is added, why not:

User-visible / Behavior Changes

List user-visible changes (including defaults/config). None

Diagram (if applicable)

For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write N/A.

Before:
[user action] -> [old state]

After:
[user action] -> [new state] -> [result]

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Running on the host
  • Model/provider: Local Ollama with qwen3.5:122b
  • Integration/channel (if any):
  • Relevant config (redacted):

Steps

Expected

Actual

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  1. look at the size of log file
 ls -lah /tmp/openclaw/openclaw-2026-03-31.log
-rw-rw-r-- 1 jyoti jyoti 569K Mar 31 22:01 /tmp/openclaw/openclaw-2026-03-31.log
  1. Filled up the file with junk until it hits 500mb
ls -lah /tmp/openclaw/openclaw-2026-03-*
-rw-rw-r-- 1 jyoti jyoti 500M Mar 31 22:05 /tmp/openclaw/openclaw-2026-03-31.log
  1. Restart gateway to force more logs. Notice that the file is rotated and moved. New logs are going into the right file
ls -lah /tmp/openclaw/openclaw-2026-03-*
-rw-rw-r-- 1 jyoti jyoti  15K Mar 31 22:07 /tmp/openclaw/openclaw-2026-03-31.log
-rw-rw-r-- 1 jyoti jyoti 500M Mar 31 22:05 /tmp/openclaw/openclaw-2026-03-31.log.1

What you personally verified (not just CI), and how:

  • Verified scenarios:
  • Edge cases checked:
  • What you did not verify:

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No)
  • Config/env changes? (Yes/No)
  • Migration needed? (Yes/No)
  • If yes, exact upgrade steps:

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk:
    • Mitigation:

Changed files

  • src/logging/log-file-fd-reopen.test.ts (added, +86/-0)
  • src/logging/log-file-partial-write.test.ts (added, +116/-0)
  • src/logging/log-file-rotation.test.ts (added, +172/-0)
  • src/logging/log-file-stale-logger.test.ts (added, +41/-0)
  • src/logging/logger.ts (modified, +248/-5)

Code Example

[openclaw] log file size cap reached; suppressing writes file=/tmp/openclaw/openclaw-2026-03-31.log maxFileBytes=524288000

---

truncate -s 0 /tmp/openclaw/openclaw-2026-03-31.log
RAW_BUFFERClick to expand / collapse

Problem

The current log file cap is 500MB with suppression (stops writing) when reached. During an infinite retry loop (e.g. from an unresolvable model), logs fill to 500MB within minutes. Once suppressed, the gateway loses all diagnostic output and eventually crashes — making it impossible to debug what went wrong.

Expected Behavior

Implement proper log rotation:

  • Max file size: 100MB per log file
  • Rotate to numbered archives (e.g. openclaw-2026-03-31.1.log, .2.log)
  • Keep N rotated files (e.g. 3-5), delete oldest
  • Never suppress logging entirely — always have a writable log file

Current Behavior

[openclaw] log file size cap reached; suppressing writes file=/tmp/openclaw/openclaw-2026-03-31.log maxFileBytes=524288000

After this message, the gateway goes dark. No more diagnostics, no crash info, nothing.

Workaround

Manual truncation:

truncate -s 0 /tmp/openclaw/openclaw-2026-03-31.log

Impact

Loss of logging during the most critical moments (when things are failing) makes debugging extremely difficult. The 500MB cap with suppression is worse than no cap at all — at least with no cap you'd still have logs.

extent analysis

TL;DR

Implement a log rotation mechanism to prevent log file size from reaching the cap and causing suppression of writes.

Guidance

  • Identify the logging configuration to determine where the log file size cap is set and modify it to implement log rotation with a max file size of 100MB.
  • Consider using a logging library or framework that supports log rotation, such as Log4j or Python's logging module with a RotatingFileHandler.
  • Set up a rotation policy to keep a specified number of archived log files (e.g., 3-5) and delete the oldest ones when the limit is reached.
  • Ensure that the logging mechanism never suppresses writes entirely, always maintaining a writable log file for diagnostic purposes.

Example

A possible implementation using Python's logging module with a RotatingFileHandler could be:

import logging
from logging.handlers import RotatingFileHandler

logger = logging.getLogger()
handler = RotatingFileHandler('/tmp/openclaw/openclaw.log', maxBytes=100*1024*1024, backupCount=5)
logger.addHandler(handler)

Notes

The exact implementation details may vary depending on the programming language, logging library, and specific requirements of the application.

Recommendation

Apply a workaround by implementing a log rotation mechanism, as this will prevent the loss of diagnostic output and allow for easier debugging of issues.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Log rotation: implement proper rotation instead of suppression at 500MB [1 pull requests, 1 participants]