Basic Configuration
Rotation Options
Size-based Rotation
'1k', '1m', '1g' or bytes (number)
Time-based Rotation
'1h' (hours), '1d' (days), '1w' (weeks). Minutes and bare numbers are not accepted.
[!NOTE] Interval rotation is evaluated when a log line is written, not on a wall-clock timer. If the process writes nothing for longer thaninterval, the file rotates on the next write — an idle process’s file can exceedintervalin age until traffic resumes. The file’s age is read from filesystem creation time, so it survives restarts.
Retention Policy
Compression
How Rotation Works
Rotation happens on write, when either configured trigger is crossed: the in-memory byte count exceedsmaxSize, or the live file’s age (from filesystem creation time) has reached interval. Both are checked after every write batch — never on a timer. Empty files are not rotated.
When a log file is rotated, it’s renamed with a timestamp and a high-resolution counter to guarantee uniqueness:
<YYYY-MM-DD-HH-MM-SS-SSS>-<hrtime>. If compression is enabled, a .gz extension is appended after rotation:
Retention
maxFiles controls how many rotated files are kept:
- A number (e.g.
10) keeps that many most-recent rotated files, deleting older ones. - A string (e.g.
'7d') keeps rotated files younger than that age, deleting older ones.
Example Configurations
Production
Development
High-Volume
Important Notes
- Empty files are not rotated
- Rotation failures don’t crash the application
- Compression runs asynchronously
- Old files are automatically cleaned up based on
maxFiles - Interval rotation is checked on write only; an idle process rotates on its next write