nginx log_format for AWStats

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

I had difficulty finding what to set nginx's log_format to in order to make AWStats read our Web server logs. Searching the Internet didn't return anything that worked, so now I've worked it out for myself I thought to post the solution here.

Our nginx config file is located in /etc/nginx/nginx.conf, yours may be somewhere else. In nginx.conf I added:

log_format main
  '$remote_addr - $remote_user [$time_local] "$request" '
  '$status $body_bytes_sent "$http_referer" '
  '"$http_user_agent"';
access_log  /var/log/nginx/$host.access.log main;

This is a double-whammie, it sets the log_format to the same as Apache (something AWStats understands) and creates a separate log file for each virtual host (site on the server).

Lastly, set the LogFormat in your to AWStats config file(s) to 1. Note: the name of the AWStats config file usually changes per-site; ours are stored in /etc/awstats.

Questions, comments and cries of, ‘UrDoingItWrong™’ are welcome. Smiling

a Padded Cell our articles site!