A transport for winston which logs to a rotating file each day.
JavaScript
Latest commit 459eb88 Jan 13, 2017 @mattberther mattberther 1.4.3

README.md

winston-daily-rotate-file

NPM version Build Status Dependency Status

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

Usage

  var winston = require('winston');
  require('winston-daily-rotate-file');

  var transport = new winston.transports.DailyRotateFile({
    filename: './log',
    datePattern: 'yyyy-MM-dd.',
    prepend: true,
    level: process.env.ENV === 'development' ? 'debug' : 'info'
  });

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

  logger.info('Hello World!');

The DailyRotateFile transport can rotate files by minute, hour, day, month, year or weekday. In addition to the options accepted by the File transport, the Daily Rotate File Transport also accepts the following options:

  • datePattern: A string representing the pattern to be used when appending the date to the filename (default 'yyyy-MM-dd'). The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day.
  • prepend: Defines if the rolling time of the log file should be prepended at the beginning of the filename (default 'false').

Valid meta characters in the datePattern are:

  • yy: Last two digits of the year.
  • yyyy: Full year.
  • M: The month.
  • MM: The zero padded month.
  • d: The day.
  • dd: The zero padded day.
  • H: The hour.
  • HH: The zero padded hour.
  • m: The minute.
  • mm: The zero padded minute.
  • ddd: The weekday (Mon, Tue, ..., Sun).

Metadata: Logged via util.inspect(meta);

LICENSE

MIT

AUTHOR: Charlie Robbins
MAINTAINER: Matt Berther