winstonjs/winston-daily-rotate-file

Name: winston-daily-rotate-file

Owner: winstonjs

Description: A transport for winston which logs to a rotating file each day.

Created: 2015-09-18 21:54:38.0

Updated: 2018-05-23 20:31:02.0

Pushed: 2018-05-10 22:00:00.0

Homepage: null

Size: 138

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

winston-daily-rotate-file

NPM version Build Status Dependency Status

A transport for winston which logs to a rotating file. Logs can be rotated based on a date, size limit, and old logs can be removed based on count or elapsed days.

Starting with version 2.0.0, the transport has been refactored to leverage the the file-stream-rotator module. Some of the options in the 1.x versions of the transport have changed. Please review the options below to identify any changes needed.

Install
install winston-daily-rotate-file
Options

The DailyRotateFile transport can rotate files by minute, hour, day, month, year or weekday. In addition to the options accepted by the logger, winston-daily-rotate-file also accepts the following options:

Usage
r winston = require('winston');
quire('winston-daily-rotate-file');

r transport = new (winston.transports.DailyRotateFile)({
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
;

ansport.on('rotate', function(oldFilename, newFilename) {
// do something fun
;

r logger = new (winston.Logger)({
transports: [
  transport
]
;

gger.info('Hello World!');

You can listen for the rotate custom event. The rotate event will pass two parameters to the callback (oldFilename, newFilename).

LICENSE

MIT

AUTHOR: Charlie Robbins MAINTAINER: Matt Berther

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.