IT

AWStats LogFormat and nginx log_format

To parse nginx logs using AWStats – their log formats need to match.

My setup is like this:

  1. nginx log_format (specified in nginx.conf file):
    log_format      main  '$remote_addr - $remote_user [$time_local] $request "$status" $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$document_root"'
  2. AWStats LogFormat (specified in your domain configuration file):
    LogFormat = "%host %other %other %time1 %method %url %other %code %bytesd %refererquot %uaquot %otherquot %otherquot"

Hope it helps 🙂

1 Comment

  1. Tu m’explique comment en mettant ça :
    “$status”

    et ça :
    %code

    Comment ton code peut marcher ?
    C’est juste un bon mythos.
    Faut enlever les guillemets du status dans nginx … sinon ça marche pas !

Leave a Reply