Use Apache rotatelogs with Nginx Log Rotation

  • Apache 服务器可以把 log 输出到一个管道(pipe)
  • Apache 提供了 rotatelogs 程序配合日志文件管理
CustomLog "|bin/rotatelogs -l /var/log/logfile-%Y%m%d 86400" common 

Nginx Log Rotation

$ mkfifo logs/error-fifo.log
$ rotatelogs -l /var/log/nginx-error-%Y%m%d.log 86400 < logs/error-fifo.log