winstonjs / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.
MIT License
899 stars 156 forks source link

winston daily rotate does not respect file size limit #360

Closed Vishal8523 closed 2 years ago

Vishal8523 commented 2 years ago

Versions: winston: ^2.4.5 winston-daily-rotate-file: ^3.10.0 Node JS: v12.22.0 OS: Debian 11 Bullseye

During the logs rotate mechanism, once the log file reaches the maxSize, the file is not rotated. Considering multiple node processes are writing to the same log file.

Winston Settings:

const logger = new winston.Logger({
    transports: [
        new winston.transports.Console({
            level: 'info',
            colorize: true,
            prettyPrint: true,
            timestamp: true
        }),
        new winston.transports.DailyRotateFile({
            filename: Logs-%DATE%.log,
            datePattern: 'YYYY-MM-DD',
            dirname: /logs/,
            level: 'info',
            json: false,
            prettyPrint: true,
            timestamp: true,
            zippedArchive: false,
            maxSize: 100m,
            maxFiles: 7d
        })
    ]
});

Request for solutions

wbt commented 2 years ago

Why do you have multiple Node processes writing to the same file? When one has a write lock that can prevent the other one from rotating it out.

Vishal8523 commented 2 years ago

Ok. Thanks for the inputs.