https://github.com/innogames/stdin-rotate
Rotates logs reading content from stdin
https://github.com/innogames/stdin-rotate
Last synced: 6 months ago
JSON representation
Rotates logs reading content from stdin
- Host: GitHub
- URL: https://github.com/innogames/stdin-rotate
- Owner: innogames
- License: mit
- Created: 2018-10-10T10:25:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T14:11:03.000Z (almost 2 years ago)
- Last Synced: 2025-03-25T02:44:13.688Z (10 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stdin-rotate
`stdin-rotate` is a small tool that redirects its `stdin` to an output file, rotating and compressing it as specified by the configuration flags.
## Why not logrotate
`logrotate` cannot handle high traffic very well. Its file backup suffix does not contain the time component, only the date (in other words, it's `-yyyymmdd`). In addition to that, backup file creation fails when the target file already exists. This 2 facts combined make `logrotate` to fail if a file needs to be rotated more than once a day.
For example, when rotating the file `application.log` at 2017.06.01, the first time a backup file whose name is `application.log-20170601` gets created. The second time the backup file already exists, so the original file (`application.log`) cannot be rotated anymore, growing until the disk is full.
In other words, `daily` is the highest log rotation rate that works, which is clearly insufficient for the logging rate of many modern applications, that can fill up the disk space in a matter of hours.
## Usage
Here is a sample usage:
```sh
./application-bin | stdin-rotate -output my-application.log -max-files 10 -max-size $((5 * 1024 * 1024))
```
Call `stdin-rotate -h` to see all the flags.