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

**URL:** <https://www.ruby-forum.com/t/proper-logformat-setting-for-awstats-for-the-default-nginx-log-output/156686>\
**Category:** NGINX\
**Created:** [January 1, 2009, 1:14am UTC](https://www.ruby-forum.com/t/proper-logformat-setting-for-awstats-for-the-default-nginx-log-output/156686 "2009-01-01T01:14:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 1, 2009, 1:14am UTC](https://www.ruby-forum.com/t/proper-logformat-setting-for-awstats-for-the-default-nginx-log-output/156686/1 "2009-01-01T01:14:18Z")

</div>

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.

I search on the 'web but all the solutions I found require changing the  
nginx  
log\_format directive first (too late now).

Does anyone know the correct AWStats LogFormat settings to process a log  
produced by the default nginx config?

Thanks,

JW

–

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 1, 2009, 10:29am UTC](https://www.ruby-forum.com/t/proper-logformat-setting-for-awstats-for-the-default-nginx-log-output/156686/2 "2009-01-01T10:29:35Z")

</div>

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
