Forever log and logrotate

igor picture igor · Apr 18, 2014 · Viewed 14.4k times · Source

I use forever to launch my nodeJs server and I choose the log file :

forever -l /home/api/log/api_output.log start server.js

I use logrotate to move logfile every day (like advise here : NodeJS/Forever archive logs), after one day my directory is like this :

-rw-r--r-- 1 root root 0 avril 18 12:00 api_output.log

-rw-r--r-- 1 root root 95492 avril 18 12:01 api_output.log-20140418

So, rotation is working, but the logs messages are now written in api_output.log-20140418, instead of api_output.log

Maybe somebody can help me ?

Answer

igor picture igor · Apr 8, 2015

I forgot copytruncate option in my config file, now it's working :

/etc/logrotate.d/api :

/home/api/log/api_output.log {
  #size 50k
  daily
  dateext
  missingok
  rotate 7
  compress
  delaycompress
  notifempty
  #create 644 root
  copytruncate  
}