winstonjs / winston-daily-rotate-file

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

watchLog option does not work #363

Open nullromo opened 1 year ago

nullromo commented 1 year ago

Code Excerpt

const fileTransportOptions: DailyRotateFileTransportOptions = {
    dirname: path.resolve(DATA_DIRECTORY, 'logs'),
    extension: '.log',
    filename: 'server-%DATE%',
    format: winston.format.combine(
        winston.format.timestamp({
            format: TIMESTAMP_FORMAT,
        }),
        winston.format.uncolorize(),
        winston.format.json(),
        winston.format.printf((info) => {
            info.message = (info.message as string).trim();
            return JSON.stringify(info);
        }),
    ),
    json: true,
    maxFiles: '30d',
    watchLog: true, // <=========================== important part here
};
const fileTransport = new DailyRotateFile(fileTransportOptions);

Steps

Run the code with the options above. Delete the log file while it's running.

Expected Behavior

The file should be regenerated and the logging should continue after the file is deleted.

Actual Bahavior

The file is not regenerated. I must restart my code for the log file to come back.

System Details

winston version: 3.7.2 winston-daily-rotate-file version: 4.6.1 winston-transport version: 4.5.0 system: WSL 2 node version: 18.7.0