关于nginx的读书笔记-日志模块

nginx日志类型

1.error.log

nginx处理http请求的错误的状态以及nginx自己错误的日志,有不一样级别html

如:nginx

#nginx错误日志配置 日志路径   日志级别
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;spa

2.access.log:

nginx处理每次http请求访问的日志,记录到该文件中,另access.log依赖log_format配置,只能配置在http模块中日志

如:orm

#日志格式     log_format的name 变量
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';htm

#nginx访问日志的配置 日志路径 log_format的name
    #access_log  logs/access.log  main;rem

nginx的日志格式是由nginx的变量组合成的,具体变量有:get

nginx变量

1.http请求变量form

1)arg_PARAMETER变量

2)http_HEADER:request中请求的head,如http_user_agent

   #log_format  main  '$http_user_agent' '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

nginx -t -c ..../nginx.conf

nginx -s reload -c ..../nginx.conf

3)sent_http_HEADER:reponse的head

2.nginx内置变量:具体参考http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log

3.自定义变量

相关文章
相关标签/搜索