Here we use ngx_log_if, which is a third-party module of Nginx.
The first step:
First go to GitHub to download the ngx_log_if address https://github.com/cfsego/ngx_log_if/, you can download the compressed package and then unzip the unzip Ngx_log_if-master.zip
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/83/CE/wKiom1d8weawHpXQAABfqDAXHvY408.png-wh_500x0-wm_3 -wmp_4-s_3342465571.png "title=" Nginxlog.png "alt=" Wkiom1d8weawhpxqaabfqdaxhvy408.png-wh_50 "/>
Step Two
Compile and install Nginx./configure--prefix=/usr/local/nginx--with-pcre--add-module=/root/ngx_log_if-master # #记得带上这个模块
Make && make install
After the installation is complete, use/USR/LOCAL/NGINX/SBIN/NGINX-V to see which modules you have installed
Step Three: note (if your host profile in vhhosts this directory, may not work, and finally configured in nginx.conf this main configuration file)
Configuring ACCESS_LOG_BYPASS_IF to the nginx.conf configuration file
server {
Location/{
access_log_bypass_if ($status = 404); #不记录404状态的所有日志信息
Access_log_bypass_if ($uri ~* ' images '); #不记录uri中所有images目录下文件的日志信息
Access_log_bypass_if ($uri = '/index.html '); #不记录uri为 Log information for/index.html
Access_log_bypass_if ($host ~* ' tonv.cc '); All log information for #不记录host为tonv. CC
}
}
Finally, the Nginx service will be restarted.
This article is from the "Drifting Away" blog, make sure to keep this source http://825536458.blog.51cto.com/4417836/1811273
Nginx settings log does not record 404 or 200 or other log information