
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
winston-daily-rotate-file
Advanced tools
A transport for winston which logs to a rotating file each day.
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 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.
Starting with version 5.0.0 this module also emits an "error" event for all low level filesystem error cases. Make sure to listen for this event to prevent crashes in your application.
This library should work starting with Node.js 8.x, but tests are only executed for Node.js 14+. Use on your own risk in lower Node.js versions.
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' })audit_file. If not specified, a file name is generated that includes a hash computed from the options object, and uses the dirname option value as the directory. (default: <dirname>/.<optionsHash>-audit.json)createLogger method will be used var winston = require('winston');
require('winston-daily-rotate-file');
var transport = new winston.transports.DailyRotateFile({
level: 'info',
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});
transport.on('error', error => {
// log or handle errors here
});
transport.on('rotate', (oldFilename, newFilename) => {
// do something fun
});
var logger = winston.createLogger({
transports: [
transport
]
});
logger.info('Hello World!');
using multiple transports
var winston = require('winston');
require('winston-daily-rotate-file');
var transport1 = new winston.transports.DailyRotateFile({
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});
var transport2 = new winston.transports.DailyRotateFile({
level: 'error',
filename: 'application-error-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});
transport1.on('error', error => {
// log or handle errors here
});
transport2.on('error', error => {
// log or handle errors here
});
transport1.on('rotate', function(oldFilename, newFilename) {
// do something fun
});
transport2.on('rotate', function(oldFilename, newFilename) {
// do something fun
});
var logger = winston.createLogger({
level: 'info'
transports: [
transport1, // will be used on info level
transport2 // will be used on error level
]
});
logger.info('Hello World!');
logger.error('Hello Error!');
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('error', error => {
// log or handle errors here
});
transport.on('rotate', (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('error', error => {
// log or handle errors here
});
transport.on('rotate', (oldFilename, newFilename) => {
// do something fun
});
const logger = winston.createLogger({
transports: [
transport
]
});
logger.info('Hello World!');
This transport emits the following custom events:
MIT
5.0.0 (2024-02-09)
This package provides a stream that writes logs to a file and rotates it based on time or size, similar to winston-daily-rotate-file. It is not tied to any specific logging library and can be used with any Node.js stream-compatible logging tool.
Similar to winston-daily-rotate-file, this package is used to rotate logs on a time basis. It does not depend on winston and can be used independently to manage log file rotation in any Node.js application.
This package is a rotating file stream for the Bunyan logging library. It offers functionality similar to winston-daily-rotate-file but is specifically designed to work with Bunyan instead of winston.
FAQs
A transport for winston which logs to a rotating file each day.
The npm package winston-daily-rotate-file receives a total of 793,603 weekly downloads. As such, winston-daily-rotate-file popularity was classified as popular.
We found that winston-daily-rotate-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.