# winston-logrotate

> Log rotating transport for Winston

Latest version **1.3.0** (published 2017-08-16) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install winston-logrotate
pnpm add winston-logrotate
yarn add winston-logrotate
bun add winston-logrotate
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2017-08-16 |
| First published | 2016-01-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | bkutil, davidvgalbraith, demmer, mstemm |
| Keywords | winston, logrotate |

## Links

- npm: https://www.npmjs.com/package/winston-logrotate
- Repository: https://github.com/juttle/winston-logrotate
- Issues: https://github.com/juttle/winston-logrotate/issues
- npm.io page: https://npm.io/package/winston-logrotate

## Dependencies (4)

- [winston](https://npm.io/package/winston.md) ^2.1.0
- [bluebird](https://npm.io/package/bluebird.md) 2.9.30
- [fs-extra](https://npm.io/package/fs-extra.md) 0.24.0
- [logrotate-stream](https://npm.io/package/logrotate-stream.md) 0.2.5

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2017-08-16
- 1.2.0 — 2017-07-06
- 1.1.0 — 2017-07-05
- 1.0.1 — 2017-02-10
- 1.0.0 — 2016-01-13

## README

# winston-logrotate

[![Build Status](https://travis-ci.org/juttle/winston-logrotate.svg)](https://travis-ci.org/juttle/winston-logrotate)

## Overview

Winston's default [file
transport](https://github.com/flatiron/winston/blob/master/lib/winston/transports/file.js)
rotation creates new logs daily, or if the file exceeds a max size, but it does
not expunge old logs. This means that an additional module must be used to
delete old log files.

`winston-logrotate` provides a transport with full support for size based
rotation, compression and pruning log files.

`winston-logrotate` uses
[logrotate-stream](https://www.npmjs.org/package/logrotate-stream) under the
covers, which is used to perform compression/rotation and winston's
`common.log` to get timestamps, colorization, and log formatting.

## Options

| Field           | Required      | Description  |
| --------------- |-------------- | ----------------------------------- |
| file      | yes | The filename of the logfile to write output to.      |
| colorize  | no  | Boolean flag indicating if we should colorize output.|
| timestamp | no  | Boolean flag indicating if we should prepend output with timestamps (default false). If function is specified, its return value will be used instead of timestamps. |
| json      | no  | If true, messages will be logged as JSON (default true). |
| size      | no  | The max file size of a log before rotation occurs. Supports 1024, 1k, 1m, 1g. Defaults to 100m |
| keep      | no  | The number of rotated log files to keep (including the primary log file). Defaults to 5 |
| compress  | no  | Optionally compress rotated files with gzip. Defaults to true. |

## Usage

Require:

```
require('winston-logrotate');
```

Create a rotate transport:

```
var rotateTransport = new winston.transports.Rotate({
        file: '/tmp/my.log', // this path needs to be absolute
        colorize: false,
        timestamp: true,
        json: false,
        size: '100m',
        keep: 5,
        compress: true
});

```

and add it to default winston logger:

```
winston.add(rotateTransport)
```

or create a custom logger using the transport:

```
var logger = new (winston.Logger)({ transports: [rotateTransport] });
```

---
_Source: https://npm.io/package/winston-logrotate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
