-
Notifications
You must be signed in to change notification settings - Fork 14.7k
feat: support configurable log rotation strategies #12960
Copy link
Copy link
Open
Description
Feature Request
Problem
Currently, Log.init creates a new log file on every startup (timestamped filename like 2026-02-10T142345.log). For long-running sessions or server deployments, this means:
- Logs from the same day are split across multiple files
- No way to customize the log directory
- Cleanup is based on file count, not time-based retention
Proposed Solution
Introduce a rotate option to Log.Options with pluggable strategies:
startup(default) — current behavior, one file per startup, retain N filesdaily— one file per day (opencode-YYYY-MM-DD.log), same-day restarts append, retain N days
Also add an optional path field to override the default log directory.
Both are controlled via environment variables:
OPENCODE_LOG_PATH— custom log directoryOPENCODE_LOG_ROTATE=daily— enable daily rotationOPENCODE_LOG_RETENTION=N— retention count
Why
Useful for server deployments on cloud: you can customize the log path to integrate with cloud provider log systems (e.g., CloudWatch, Cloud Logging) for easier log collection and querying.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels