Proper LogFormat setting for AWstats for the default nginx log output?

William Ross will at spanner.org
Thu Jan 1 12:16:35 MSK 2009


On 1 Jan 2009, at 00:00, JW wrote:

> Hello,
>
> I have several days worth of Nginx logs that I need to run through  
> AWstats.
>
> I tried leaving LogFormat=1 in the awstats config (which is correct  
> for the
> default apache logs) but that doesn't work.

If your logs are the same as mine then the problem is a double space  
that nginx leaves in each log entry between the status code and the  
bytes sent. I tried various ways of specifying the double space but  
without success - it seems they collapse spaces in the logformat  
settings line but not in the file itself - so I gave up and now just  
run:

   perl -pi -e 's/  / /g' ./nginx.access.log

before an awstats run. With that, I can just use this configuration  
line:

   LogFormat="%host %other %logname %time1 %methodurl %code %bytesd  
%refererquot %uaquot %otherquot"

Which is the default with an added %otherquot for the final  
http_x_forwarded_for that nginx adds by default.

I guess by specifying the log format in nginx I could eliminate the  
problem, but like you I always come to it with a load of existing  
logfiles to process.

best,

will






More information about the nginx mailing list