ngx_http_log_module用来定义请求日志格式
1. access_log指令
  语法:   access_log path [format [buffer=size [flush=time]]]
      access_log path format gzi=[level] [buffer=size] [flush=time]
      access_log syslog:server=address[,paramter=value] [format];
      access_log off;
      默认值:access_log logs/access.log combined;
      配置段:http,server,location,if in location, limit_except
      gzip压缩等级
      buffer设置内存缓冲区大小
      flush保存在缓冲区中的最长时间
      不记录日志:access_log off #好像没作用
2. log_format指令
    语法:log_format name string ......
    配置段:http
    name 表示格式名称,string表示定义的格式
    log_format combined '$remote_addr - $remote_user [$time_local]'
        '"$request" $status $body_tytes_sent'
        ' $http_referer "$http_user_agent"'

    log_format proxy '$http_x_forwarded_for - $remote_user [$time_local]'
          '"$request" $status $body_bytes_sent'
          ' "$http_referer " " $http_user_agent"';
3. 日志格式允许包含的变量:
  $remote_addr, $http_x_forwarded_for 记录客户端IP地址
  $remote_user         记录客户端名称
  $request             记录请求的URL和HTTP协议
  $status           记录请求状态
  $body_bytes_sent       发送给客户端的字节数,不包括响应头的大小
  $bytes_sent       发送给客户端的总字节数
  $connection        链接的序列号
  $connection_requests   当前通过一个链接获得的请求数量
  $msec           日志写入时间,单位为秒,精确是毫秒
  $pipe           如果请求时通过http流水线发送,pipe值为p,否则为.
  $http_referer                记录从那个页面链接访问过来的
  $http_user_agent        记录客户端浏览器相关信息
  $request_length          请求的长度
  $request_time             请求处理时间,单位为秒,精确度毫秒
  $time_iso8601             标准格式下的本地时间
  $time_local                  通用日志格式下的本地时间
4. open_log_file_cache指令
  语法:open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time]
  默认值:open_log_file_cache off;
  配置段:http,server,location
      max:最大文件描述符数量
      inactive:存货时间,默认10s
      min_uses:设置在inactive时间段中,日志文件最少使用多少次,该日志文件描述符记入缓存中,默认1次
      valid:设置检查频率,默认60s
      off:禁用
      open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;

5. log_not_found指令
语法:log_not_found on | off
默认值:log_not_found on;
匹配段:http,server,location
是否在error_log中记录不存在的错误,默认on
6. log_subequest指令
语法:log_subrequest on | off;
默认值:log_subrequest off;
配置段:http,server,location
是否在access_log中记录子请求的访问日志,默认off
7. rewrite_log指令
由ngx_http_rewrite_module模块提供,用来记录重写日志
语法:rewrite_log on | off;
默认值 rewrite_log off;
配置段:http,server,location,if
启用时将error log中记录notice级别的重写日志
8. error_log指令
语法:error_log | stderr | syslog:server=address[,parameter=value [debug | info| notice| warn | error | crit | alert | emerg]]
默认值:error_log logs/error.log error;
配置段:main,http,server,location
配置错误日志

Nginx笔记总结九:Nginx日志配置的更多相关文章

  1. nginx启用TCP反向代理日志配置

    Nginx使用TCP反向代理日志配置不同于http 修改nginx配置文档/usr/local/nginx/conf/nginx.conf 设置日志格式 stream { log_format pro ...

  2. Nginx实战(三) 日志配置与切割

    访问日志主要记录客户端访问Nginx的每一个请求,格式可以自定义.通过访问日志,你可以得到用户地域来源.跳转来源.使用终端.某个URL访问量等相关信息. Nginx中访问日志相关指令主要有两条,一条是 ...

  3. Nginx笔记总结十七:nginx生成缩略图配置(http_image_filter_module)

    编译: ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_realip_module-- ...

  4. Nginx笔记总结十:Nginx日志切割

    1.Nginx日志切割 logrotate日志文件管理工具,通过cron程序定期执行,默认在cron默认程序的dayli目录下 [root@joker logrotate.d]# cat /etc/c ...

  5. Nginx笔记总结五:Nginx配置虚拟主机

    upstream proxy1 { server ; } upstream proxy2 { server ; } server { listen ; server_name www1.dlab.co ...

  6. Nginx笔记总结六:Nginx location配置

    语法规则:location [= | ~ | ~* | ^~] /uri/ {....} = 表示精确匹配 ^~ 表示uri以某个常规字符串开头 ~ 表示区分大小写的正则表达式 ~* 表示不区分大小写 ...

  7. springboot学习笔记:4.logback日志配置

    springboot中日志组件推荐使用logback: 由于springboot内置了logback,所以可以直接在application.properties中配置:如果要功能丰富些,则配置下log ...

  8. Nginx笔记总结二:Nginx编译参数

    -prefix=                                                    安装路径-with-http_ssl_module               ...

  9. Nginx笔记总结十三:nginx 正向代理

    server { listen ; location / { resolver 202.106.0.20 202.106.119.116; resolver_timeout 30s; proxy_pa ...

随机推荐

  1. 史上最难PHPer笔试题,40分就能月薪过万!附答案

    请批判性的学习,欢迎大牛指正错误 1.有关PHP字符串的说法,不对的是:A.如果一个脚本的编码是 ISO-8859-1,则其中的字符串也会被编码为 ISO-8859-1.B.PHP的字符串在内部是字节 ...

  2. springboot和shiro的整合

    直接贴上代码 1. 所需要的jar包 <dependency> <groupId>org.apache.shiro</groupId> <artifactId ...

  3. 谷歌发布自家物理密匙TitanKey,能让人们远离互联网“黑洞”吗?

    随着隐私泄露事件的飞速增多,人们对如何保护自身隐私安全也越来越重视.而基于这种诉求,众多企业也在持续发力安全层面.毕竟,在目前危机四伏的互联网大环境下,真正能保护人们隐私安全的服务.设备等都是&quo ...

  4. java内部类(构造spring中的接收返回数据的实体类)

    说起内部类这个词,想必很多人都不陌生,但是又会觉得不熟悉.原因是平时编写代码时可能用到的场景不多,用得最多的是在有事件监听的情况下,并且即使用到也很少去总结内部类的用法.今天我们就来一探究竟. 原文链 ...

  5. Python笔记_第一篇_面向过程_第一部分_5.Python数据类型之列表类型(list)

    Python中序列是最基本的数据结构.序列中的每个元素都分配一个数字(他的位置或者索引),第一个索引是0,第二个索引是1,依次类推.Python的列表数据类型类似于C语言中的数组,但是不同之处在于列表 ...

  6. IdentityServer4之Token令牌获取流程分析

    1.asp.net core 是基于管道模式IdentityServer会在注册一个管道处理程序 IdentityServerMiddleware 类专门处理登录验证的逻辑,本次主要讲的是access ...

  7. 5)PHP,可变变量

    所谓可变变量,就是一个变量的名,又是一个变量. 可变变量的语法是php的很特殊的语法——其他语言中少见. $v1 = “abc”; //这是一个字符串变量,其内容是字符串“abc” $abc = ; ...

  8. 第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第六天】

    https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...

  9. 【线段树】Interval GCD

    题目描述 给定一个长度为N的数列A,以及M条指令 (N≤5*10^5, M<=10^5),每条指令可能是以下两种之一: "C l r d",表示把 A[l],A[l+1],- ...

  10. Java分层架构的使用规则

    原文章引用地址:http://blog.csdn.net/ygzk123/article/details/7816511 三层结构的程序不是说把项目分成DAL, BLL, WebUI三个模块就叫三层了 ...