🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

winston-logrotate

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-logrotate

Log rotating transport for Winston

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
4
Created
Source

winston-logrotate

Build Status

Overview

Winston's default file transport 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 under the covers, which is used to perform compression/rotation and winston's common.log to get timestamps, colorization, and log formatting.

Options

FieldRequiredDescription
fileyesThe filename of the logfile to write output to.
colorizenoBoolean flag indicating if we should colorize output.
timestampnoBoolean flag indicating if we should prepend output with timestamps (default false). If function is specified, its return value will be used instead of timestamps.
jsonnoIf true, messages will be logged as JSON (default true).
sizenoThe max file size of a log before rotation occurs. Supports 1024, 1k, 1m, 1g. Defaults to 100m
keepnoThe number of rotated log files to keep (including the primary log file). Defaults to 5
compressnoOptionally 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] });

Keywords

winston

FAQs

Package last updated on 16 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts