https://github.com/tryghost/bunyan-rotating-file-stream
Rotate bunyan logs based on time period and file-size threshold
https://github.com/tryghost/bunyan-rotating-file-stream
Last synced: 3 months ago
JSON representation
Rotate bunyan logs based on time period and file-size threshold
- Host: GitHub
- URL: https://github.com/tryghost/bunyan-rotating-file-stream
- Owner: TryGhost
- License: mit
- Created: 2021-03-03T10:44:21.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-10-03T22:23:04.000Z (3 months ago)
- Last Synced: 2025-10-04T00:22:19.941Z (3 months ago)
- Language: JavaScript
- Size: 68.4 KB
- Stars: 3
- Watchers: 9
- Forks: 2
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bunyan Rotating Filestream
## Install
`npm install @tryghost/bunyan-rotating-filestream --save`
or
`yarn add @tryghost/bunyan-rotating-filestream`
## Usage
Create a bunyan logger using the stream:
```js
var log = bunyan.createLogger({
name: 'foo',
streams: [{
stream: new RotatingFileStream({
path: '/var/log/foo.log',
period: '1d', // daily rotation
totalFiles: 10, // keep up to 10 backup copies
rotateExisting: true, // Give ourselves a clean file when we start up, based on period
threshold: '10m', // Rotate log files larger than 10 megabytes
totalSize: '20m', // Don't keep more than 20mb of archived log files
gzip: true // Compress the archive log files to save space
})
}]
});
```
Other options include `startNewFile` to always open a new file on start-up.
## Develop
1. `git clone` this repo & `cd` into it as usual
2. Run `yarn` to install top-level dependencies.
## Test
- `yarn lint` run just eslint
- `yarn test` run lint and tests
## Publish
- `yarn ship`
## Credit
Many thanks to @Rcomian for their work on the original bunyan-rotating-file-stream project, this project borrows lots of the code and all of the ideas in the original.
# Copyright & License
Copyright (c) 2013-2025 Ghost Foundation - Released under the [MIT license](LICENSE).