# @tryghost/bunyan-rotating-filestream

Latest version **0.0.20** (published 2026-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tryghost/bunyan-rotating-filestream
pnpm add @tryghost/bunyan-rotating-filestream
yarn add @tryghost/bunyan-rotating-filestream
bun add @tryghost/bunyan-rotating-filestream
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.0.20 |
| Published | 2026-09-11 |
| First published | 2021-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | Ghost Foundation |
| Maintainers | zimoatghost, allouis, kernalghost, chrisraible, erisds, johnonolan, kevinansfield, cobbspur, aileencgn, jloh, minimaluminium, sam-lord, pauladamdavis, bobvaneck, joeegrigg, hadret, erik-ghost, sagzy, vershwal, zach1618, mike182uk, luissazevedo, lsinger, nickmoreton, renatoworks, rblstr-ghost, evanhahn-ghost, austin.burdine, weylandswart, ghost-slimer, tmciesco, jonatan-ghost, 9larsons |

## Links

- npm: https://www.npmjs.com/package/@tryghost/bunyan-rotating-filestream
- Repository: https://github.com/TryGhost/framework
- npm.io page: https://npm.io/package/@tryghost/bunyan-rotating-filestream

## Dependencies (1)

- [long-timeout](https://npm.io/package/long-timeout.md) ^0.1.1

## Recent versions

- 0.0.20 (latest) — 2026-09-11
- 0.0.19 — 2026-09-03
- 0.0.18 — 2026-09-01
- 0.0.17 — 2026-09-01
- 0.0.16 — 2026-08-26
- 0.0.15 — 2026-08-20
- 0.0.14 — 2026-08-17
- 0.0.13 — 2026-08-12
- 0.0.12 — 2026-07-23
- 0.0.11 — 2026-07-22
- 0.0.10 — 2026-07-20
- 0.0.9 — 2026-07-20
- 0.0.8 — 2026-07-15
- 0.0.7 — 2021-03-04
- 0.0.6 — 2021-03-03
- … 5 more at https://npm.io/package/@tryghost/bunyan-rotating-filestream/versions

## README

# Bunyan Rotating Filestream

## Install

`npm install @tryghost/bunyan-rotating-filestream --save`

or

`pnpm add @tryghost/bunyan-rotating-filestream`

## Purpose

A rotating file stream for the [bunyan](https://github.com/trentm/node-bunyan) logger, supporting period-based and size-based rotation, gzip compression of archives, and limits on the number and total size of archived files.

## Usage

Create a bunyan logger using the stream:

```js
const 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.

### Flushing

Writes are queued and written asynchronously, so a process that exits right
after logging can lose the last lines. `flush()` drains everything written so
far to disk and leaves the stream open:

```js
log.error('fatal boot error');
await stream.flush();
process.exit(1);
```

Use `end()` instead when shutting the stream down for good — it also drains the
queue, but closes the file handles and stops rotation.

## Develop

This is a mono repository, managed with [Nx](https://nx.dev).

Follow the instructions for the top-level repo.

1. `git clone` this repo & `cd` into it as usual
2. Run `pnpm install` to install top-level dependencies.

## Run

- `pnpm dev`

## Test

- `pnpm lint` runs oxlint
- `pnpm test` runs lint and tests

## 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-2026 Ghost Foundation - Released under the [MIT license](LICENSE).

---
_Source: https://npm.io/package/@tryghost/bunyan-rotating-filestream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
