openclaw - ✅(Solved) Fix [Feature]: log rotation support [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#66394Fetched 2026-04-15 06:26:19
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Log approach does not support automatic log rotation; once the log file reaches 500MB it simply stops writing without creating a new file, and combined with a short 24-hour retention period and cleanup only at startup, it may lead to loss of historical logs. It is recommended to introduce the rotating-file-stream library to implement production-grade log rotation functionality. tslog also recommends using rotating-file-stream (see: [https://github.com/fullstack-build/tslog]).

Combine it with tslog:

import { Logger } from "tslog";
import { createStream } from "rotating-file-stream";

const stream = createStream("tslog.log", {
  size: "10M", // rotate every 10 megabytes written
  interval: "1d", // rotate daily
  compress: "gzip", // compress rotated log files
});

const logger = new Logger();

logger.attachTransport((logObj) => {
  stream.write(JSON.stringify(logObj) + "\n");
});

Root Cause

Log approach does not support automatic log rotation; once the log file reaches 500MB it simply stops writing without creating a new file, and combined with a short 24-hour retention period and cleanup only at startup, it may lead to loss of historical logs. It is recommended to introduce the rotating-file-stream library to implement production-grade log rotation functionality. tslog also recommends using rotating-file-stream (see: [https://github.com/fullstack-build/tslog]).

Combine it with tslog:

import { Logger } from "tslog";
import { createStream } from "rotating-file-stream";

const stream = createStream("tslog.log", {
  size: "10M", // rotate every 10 megabytes written
  interval: "1d", // rotate daily
  compress: "gzip", // compress rotated log files
});

const logger = new Logger();

logger.attachTransport((logObj) => {
  stream.write(JSON.stringify(logObj) + "\n");
});

Fix Action

Fixed

PR fix notes

PR #66457: fix(logging): implement log file rotation and update related tests

Description (problem / solution / changelog)

##Issue Number : #66394

Summary

Describe the problem and fix in 2–5 bullets:

If this PR fixes a plugin beta-release blocker, title it fix(<plugin-id>): beta blocker - <summary> and link the matching Beta blocker: <plugin-name> - <summary> issue labeled beta-blocker. Contributors cannot label PRs, so the title is the PR-side signal for maintainers and automation.

  • Problem:
  • Why it matters:
  • What changed:
  • What did NOT change (scope boundary):

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

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Root Cause (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:
  • Contributing context (if known):

Regression Test Plan (if applicable)

For bug fixes or regressions, name the smallest reliable test coverage that should catch 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).
If none, write 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? (Yes/No)
  • Secrets/tokens handling changed? (Yes/No)
  • New/changed network calls? (Yes/No)
  • Command/tool execution surface changed? (Yes/No)
  • Data access scope changed? (Yes/No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS:
  • Runtime/container:
  • Model/provider:
  • 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)

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

  • docs/logging.md (modified, +5/-0)
  • extensions/acpx/src/config.ts (modified, +1/-1)
  • extensions/acpx/src/runtime.test.ts (modified, +158/-2)
  • extensions/acpx/src/runtime.ts (modified, +182/-6)
  • extensions/acpx/src/service.test.ts (modified, +35/-2)
  • extensions/acpx/src/service.ts (modified, +1/-3)
  • src/config/types.base.ts (modified, +1/-1)
  • src/logger.test.ts (modified, +5/-1)
  • src/logging/log-file-size-cap.test.ts (modified, +18/-7)
  • src/logging/logger.ts (modified, +73/-5)

Code Example

import { Logger } from "tslog";
import { createStream } from "rotating-file-stream";

const stream = createStream("tslog.log", {
  size: "10M", // rotate every 10 megabytes written
  interval: "1d", // rotate daily
  compress: "gzip", // compress rotated log files
});

const logger = new Logger();

logger.attachTransport((logObj) => {
  stream.write(JSON.stringify(logObj) + "\n");
});
RAW_BUFFERClick to expand / collapse

Summary

Log approach does not support automatic log rotation; once the log file reaches 500MB it simply stops writing without creating a new file, and combined with a short 24-hour retention period and cleanup only at startup, it may lead to loss of historical logs. It is recommended to introduce the rotating-file-stream library to implement production-grade log rotation functionality. tslog also recommends using rotating-file-stream (see: [https://github.com/fullstack-build/tslog]).

Combine it with tslog:

import { Logger } from "tslog";
import { createStream } from "rotating-file-stream";

const stream = createStream("tslog.log", {
  size: "10M", // rotate every 10 megabytes written
  interval: "1d", // rotate daily
  compress: "gzip", // compress rotated log files
});

const logger = new Logger();

logger.attachTransport((logObj) => {
  stream.write(JSON.stringify(logObj) + "\n");
});

Problem to solve

Log approach does not support automatic log rotation; once the log file reaches 500MB it simply stops writing without creating a new file, and combined with a short 24-hour retention period and cleanup only at startup, it may lead to loss of historical logs.

Proposed solution

It is recommended to introduce the rotating-file-stream library to implement production-grade log rotation functionality.

Alternatives considered

No response

Impact

.

Evidence/examples

No response

Additional information

No response

extent analysis

TL;DR

Introduce the rotating-file-stream library to implement automatic log rotation and prevent loss of historical logs.

Guidance

  • Import the rotating-file-stream library and create a stream with the desired rotation settings, such as size and interval.
  • Attach the stream to the tslog logger using the attachTransport method.
  • Configure the stream to compress rotated log files to save storage space.
  • Test the log rotation functionality to ensure it works as expected and adjust settings as needed.

Example

import { Logger } from "tslog";
import { createStream } from "rotating-file-stream";

const stream = createStream("tslog.log", {
  size: "10M", 
  interval: "1d", 
  compress: "gzip", 
});

const logger = new Logger();

logger.attachTransport((logObj) => {
  stream.write(JSON.stringify(logObj) + "\n");
});

Notes

The provided example code snippet demonstrates how to integrate rotating-file-stream with tslog, but you may need to adjust the rotation settings and file path to fit your specific use case.

Recommendation

Apply the workaround by introducing the rotating-file-stream library, as it provides a production-grade log rotation functionality that can help prevent loss of historical logs.

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 [Feature]: log rotation support [1 pull requests, 1 participants]