How to avoid 404 for images in access log?

Reinis Rozitis r at roze.lv
Thu Sep 22 16:16:05 UTC 2011


> My access log is full of 404 logs for images not found; thus, it is difficult to find real 200 successful visits. The lines 
> include
> ... GET /css/img/calendar.png HTTP/1.1"  404 31
> "http://mydomain.com.page.html ...


Depending on if you don't want to log 404 requests at all or just for the images can probably do something like this:


location ~* ^.+\.(jpg|jpeg|gif|png)$ {
    error_page 404 @nolog;
}

location @nolog {
   access_log off;
}


If you want it for any request just use the error_page without location or even give a different logfile for the 404s.

rr 



More information about the nginx mailing list