NodeJS/Forever archive logs

我们两清 提交于 2019-12-02 17:38:00
mak

forever itself doesn't support log rotation and log rotation is still a pending feature request for Winston.

You can use logrotate which is included in most Linux distributions and is used for rotating system log files, as well as used by other software like Apache.

Add a file to /etc/logrotate.d/

/path/to/server.log {
  daily         # how often to rotate
  rotate 10     # max num of log files to keep
  missingok     # don't panic if the log file doesn't exist
  notifempty    # ignore empty files
  compress      # compress rotated log file with gzip
  sharedscripts # postrotate script (if any) will be run only once at the end, not once for each rotated log
  copytruncate  # needed for forever to work properly
  dateext       # adds date to filename 
  dateformat %Y-%m-%d.
}

See more logrotate examples.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!