Coder Social home page Coder Social logo

winston-logrotate's Introduction

winston-logrotate (LOOKING FOR NEW MAINTAINER)

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

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.
label no Optionally label entries in the log with the given label.
stringify no Optionally overwrite the default stringify method.

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] });

winston-logrotate's People

Contributors

bkutil avatar demmer avatar fastliketree avatar jharmelink avatar joeenzminger avatar obermillerk avatar seidel-michael avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.