[英]Node.js process continues to write to old log file
I am having some trouble setting up log rotation for my node.js server. 我在为node.js服务器设置日志轮转时遇到麻烦。 It seems that the process continues to write to the old file.
似乎该过程继续写入旧文件。 My log rotation config is as follows:
我的日志轮换配置如下:
/var/log/node.js.log {
daily
rotate 1
maxsize 20M
su root root
create 0700 root root
missingok
compress
sharedscripts
}
When the logrotation script runs, the new log stays at 0 bytes, and by running lsof | grep deleted
运行logrotation脚本时,通过运行
lsof | grep deleted
,新日志将保持为0字节lsof | grep deleted
lsof | grep deleted
I can see that the old log file continues to grow, eventually filling up all the disk on the machine. lsof | grep deleted
我可以看到旧的日志文件继续增长,最终填满了计算机上的所有磁盘。 Do I really have to restart the node.js process every time I rotate the log? 每次轮换日志时,是否真的必须重新启动node.js进程吗?
可以使用logrotate中的copytruncate
选项重新使用当前写入的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.