1,安装cronolog
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
tar zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
mkdir -p /usr/local/cronolog
./configure --prefix=/usr/local/cronolog
make
make install
 
2,创建一个命名管道
mkfifo /data/access_log_pipe
 
3,配置cronolog:
nohup cat /data/access_log_pipe | /usr/local/cronolog/sbin/cronolog /data/logs/%Y%m%d/%Y%m%d%H%M.log &
 
4,配置nginx.conf日志
log_format post_tracking '{\"ip\":\"$remote_addr\",\"request\":\"$request\",\"body\":\"$request_body\",\"time\":\"$time_local\",\"status\":\"$status\"}';
access_log  /data/access_log_pipe post_tracking; 
 
5,重启Nginx
kill -HUP `cat /usr/local/webserver/nginx/nginx.pid`