这个初始化过程非常容易理解,之后其他的日志操作也都在这个文件中,我们遇到之后再进行详细讲解
函数执行后,返回 ngx_log 结构的地址
ngx_log 结构取值如下:
{ log_level = 6, file = 0x80e3000 <ngx_log_file>, connection = 0, handler = 0x0, data = 0x0, writer = 0x0, wdata = 0x0, action = 0x0, next = 0x0}
file 字段取值:
{ fd = 3, name = { len = 0, data = 0x0 }, flush = 0x0, data = 0x0}
使用ngx_log_if不记录特定日志
第一步:
先到Github下载ngx_log_if地址https://github.com/cfsego/ngx_log_if/
第二步:
安装第三方模块到Nginx。第三方模块的安装可以参考http://wiki.nginx.org/3rdPartyModules 使用--add-module添加解压后的ngx_log_if如下
./configure --add-module=/var/local/ngx_log_if-master
然后再编译安装Nginx即可。
第三步:
配置access_log_bypass_if到nginx.conf配置文件中
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为/index.html的日志信息 access_log_bypass_if ($host ~* 'tonv.cc'); #不记录host为tonv.cc的所有日志信息 }}
重启Nginx即可过滤不显示特定的日志了