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

Facing EPERM Issue while oprning file. #369

Open vishalshingate opened 1 year ago

vishalshingate commented 1 year ago

I have a daily limit of files of 10. if that limit reaches audit.json gets updated but files from windows are not getting deleted until the application restart and that file is not accessible getting an EPERM error.

EPERM: operation not permitted, open 'C:\FLOW2\PM2\logs\engine_out-2023-03-21.log'

const { createLogger, transports, format } = require('winston'); let outTransporter = new (transports.DailyRotateFile)({ level: 'trace', levelOnly: false, filename: microServiceName +'_out-%DATE%.log', dirname: logPath, datePattern: rotationPattern, maxSize: maxSize, maxFiles: maxFiles, auditFile: auditFilePath }); let errorTransporter = new (transports.DailyRotateFile)({ level: 'error', levelOnly: true, filename: microServiceName +'_error-%DATE%.log', dirname: logPath, datePattern: rotationPattern, maxSize: maxSize, maxFiles: maxFiles, auditFile: auditFilePath }); I guess this is related to this https://github.com/winstonjs/winston-daily-rotate-file/issues/261