logwriter
A Go-based log management utility that wraps command execution, captures output to log files, and automatically manages log retention based on time and disk space constraints.
Features
- Wraps any command and captures stdout/stderr to dated log files
- Automatic log rotation based on age or disk space
- Flexible log naming patterns (flat or hierarchical)
- Cron-based scheduled cleanup
- Zero application changes required
Quick Start
Installation
go mod tidy
go build -o logwriter
Configuration
Create /etc/logging.json:
{
"prefix": "myapp",
"log_path": "/var/log/myapp",
"log_pattern": "flat",
"config_path": "/etc/myapp/config.json",
"default_cron": "0 0 * * *",
"time": {
"enabled": true,
"path": "logging.max_days",
"cron_path": "logging.time_cron"
},
"space": {
"enabled": true,
"path": "logging.max_gb",
"cron_path": "logging.space_cron"
}
}
Usage
logwriter your-command --with-args
Documentation
For comprehensive documentation including configuration options, integration examples, and troubleshooting, see docs/DOCUMENTATION.md.
License
MIT