|
1 bulan lalu | |
---|---|---|
.. | ||
LICENSE | 1 bulan lalu | |
README.md | 1 bulan lalu | |
daily-rotate-file.js | 1 bulan lalu | |
index.d.ts | 1 bulan lalu | |
index.js | 1 bulan lalu | |
package.json | 1 bulan lalu |
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.
Please note that if you are using winston@2
, you will need to use winston-daily-rotate-file@3
. winston-daily-rotate-file@4
removed support for winston@2
.
npm install winston-daily-rotate-file
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:
datePattern
for the rotation times. (default: null)%DATE%
placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%'){ flags: 'a' }
) var winston = require('winston');
require('winston-daily-rotate-file');
var transport = new winston.transports.DailyRotateFile({
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});
transport.on('rotate', function(oldFilename, newFilename) {
// do something fun
});
var logger = winston.createLogger({
transports: [
transport
]
});
logger.info('Hello World!');
import * as winston from 'winston';
import 'winston-daily-rotate-file';
const transport = new winston.transports.DailyRotateFile({
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});
transport.on('rotate', function(oldFilename, newFilename) {
// do something fun
});
const logger = winston.createLogger({
transports: [
transport
]
});
logger.info('Hello World!');
import * as winston from 'winston';
import DailyRotateFile from 'winston-daily-rotate-file';
const transport: DailyRotateFile = new DailyRotateFile({
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});
transport.on('rotate', function(oldFilename, newFilename) {
// do something fun
});
const logger = winston.createLogger({
transports: [
transport
]});
logger.info('Hello World!');
This transport emits the following custom events:
MIT