A Go log rolling library with size-based, time-based, and manual rotation, plus compression.
Timberjack is a Go library for log file rotation, enabling developers to automatically manage log files based on size, time intervals, or scheduled clock times. It solves the problem of log files growing indefinitely by rotating, compressing, and cleaning up old logs, ensuring efficient disk usage and organized log archives.
Go developers building long-running applications like servers, daemons, or microservices that require persistent, manageable logging without external dependencies.
Developers choose Timberjack for its enhanced feature set over alternatives, including multiple rotation strategies, modern compression support (gzip/zstd), and fine-grained control over backup naming and cleanup, all while maintaining compatibility with Go's standard logging interfaces.
Timberjack is a Go log rolling library with support for size-based, time-based, and manual rotation.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Adds time-based and clock-scheduled rotation to size-based logging, allowing precise control like daily intervals or specific minute alignments, as shown in the configuration example with RotationInterval and RotateAt.
Offers gzip and Zstandard (zstd) compression for rotated logs, enabling efficient disk space savings with opt-in settings detailed in the Compression field.
Works with any logger using io.Writer, including the standard log package, making it easy to integrate without modifying existing logging code, as demonstrated in the import and example.
Deletes old backups based on MaxBackups and MaxAge limits, and compresses uncompressed logs if enabled, reducing manual maintenance during rotation cleanup.
Provides configurable backup filename patterns with BackupTimeFormat and AppendTimeAfterExt for better shell completion, plus FileMode for custom permissions on new files.
The legacy Compress field is deprecated and will be removed in v2, forcing migration efforts and potential compatibility issues for users with old configurations.
When multiple rotation strategies like RotationInterval and RotateAtMinutes are set, they can conflict, as scheduled rotations reset interval timers, leading to unpredictable rotation schedules as warned in the README.
Requires explicit logger.Close() calls to avoid goroutine leaks and open file handles from background scheduled rotations, adding lifecycle management burden that can cause issues if neglected.
Designed for one process per log file, with the README warning against reuse from multiple processes, making it unsuitable for distributed or concurrent logging scenarios without workarounds.