永远记录并logrotate [英] Forever log and logrotate

查看:98
本文介绍了永远记录并logrotate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我永远用它来启动我的nodeJs服务器,然后选择日志文件:

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

永远-l/home/api/log/api_output.log启动server.js

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

我每天都使用logrotate移动日志文件(例如在此处建议: NodeJS/Forever存档日志),一天后,我的目录如下:

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 0 avril 18 12:00 api_output.log

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

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

因此,轮换工作正常,但是日志消息现在写在api_output.log-20140418中,而不是api_output.log

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 ?

推荐答案

我忘记了配置文件中的copytruncate选项,现在它可以正常工作了:

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

/etc/logrotate.d/api:

/etc/logrotate.d/api :

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

这篇关于永远记录并logrotate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆