keymetrics / pm2-logrotate

Automatically rotate all applications logs managed by PM2
1.24k stars 138 forks source link

Log file rewrite (not appended) if time range lower than time mask #181

Open andrejs82git opened 2 years ago

andrejs82git commented 2 years ago

Hi!

I was try to use pm2-logrotate with that params

And it work fine, exclude one thing, - every new minutecreating new empty logfile and write new portion from main log file.

I am not familiar with pm2-logrotate code, but i found code that looks like can fixing that befavior.

--var writeStream = fs.createWriteStream(final_name, {'flags': 'w+'});
++var writeStream = fs.createWriteStream(final_name, {'flags': 'a+'});

just change w+ to a+, i think it will logical. It will append one more portion of log file and not dangerous to delete useful information.

Thanks a lot!