A Go package for writing logs to rolling files with configurable size, age, and backup limits.
Lumberjack is a Go package that provides a rolling logger for writing application logs to files with automatic rotation and cleanup. It acts as a pluggable file management layer that integrates with any logging library capable of writing to an io.Writer, such as Go's standard log package. It solves the problem of managing log file growth by automating rotation, retention, and compression.
Go developers who need a reliable, lightweight solution for file-based log management within their existing logging infrastructure, particularly those building long-running services or applications that generate substantial log data.
Developers choose Lumberjack for its focused, single-responsibility design that seamlessly integrates with Go's standard logging interfaces, offering automatic log rotation, configurable retention, and optional compression without requiring a full logging framework replacement.
lumberjack is a log rolling package for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Rotates log files when they reach the configurable MaxSize in megabytes, preventing unbounded disk usage as detailed in the Logger struct.
Allows precise control over backup files with MaxBackups and MaxAge settings, enabling efficient log cleanup without manual intervention.
Implements io.Writer and io.Closer, making it drop-in compatible with Go's standard log package and any logging library that supports io.Writer, as shown in the example code.
Supports compressing rotated log files with gzip to save disk space, configurable via the Compress field in the Logger.
The README explicitly states it assumes only one process writes to the output files, causing conflicts and improper behavior in multi-process setups.
Lacks support for log levels, structured formats, or remote logging; it only manages file writes, requiring integration with other libraries for full functionality.
For use cases like SIGHUP-triggered rotation, developers must write additional boilerplate code, as illustrated in the Rotate() example, adding complexity.