problem with split log

Igor Sysoev is at
Thu Mar 13 10:28:48 MSK 2008

On Thu, Mar 13, 2008 at 02:03:47PM +0700, dika wrote:

> Unfortunately nginx doesn't support piping log method inside it's config 
> script, so you have to set it separately.
> try this:
> ~ point your access/error log to a file, such as /logs/access.log/ and 
> /logs/error.log/
> ~ if /logs/access.log/ and /logs/error.log/ has been exist, delete them, 
> and recreate as fifo's
> ~ /mkfifo logs/access.log logs/error.log/
> ~ make a .sh files to put a cronolog script and piping, like:
> #!/bin/bash
> |(cat /usr/local/nginx/logs/access.log |/usr/local/sbin/cronolog -l 
> /var/log/nginx/access.log \
> /var/log/nginx/%Y/%m/%d/%H/access.log) &
> (cat /usr/local/nginx/logs/error.log |/usr/local/sbin/cronolog -l 
> /var/log/nginx/error.log \
> /var/log/nginx/%Y/%m/%d/%H/error.log) &|
> ~ start/execute thus file whenever you start your nginx
> Source and references:

This is total overkill for such trivial operation as hourly log rotation:

nginx writes to fifo
cat reads from fifo
cat writes to pipe
cronolog read from pipe

3 useless process context switches and 3 useless copy operations for
each request or buffered bunch of requests.

The cronolog is usefull with Apache because Apache can not rotate logs
immidiately. But nginx rotates logs in a moment.

Igor Sysoev

More information about the nginx mailing list