为了节省硬盘,只记录请求失败的日志

需要定义一个map,设置只有2xx或者3xx的请求不做记录。

1
2
3
4
5
6
map $status $loggable {
    ~^[23] 0;
    default 1;
}

access_log /var/log/nginx/access.log combined if=$loggable;