在nginx.conf文件或vhosts/*.conf文件中的access_log日志中指定级别为main。

http {
include mime.types;
default_type application/octet-stream; log_format main '$remote_addr - [$time_iso8601] - $msec - $status - $request_time - $body_bytes_sent - "$http_host" - "$request" - "$http_referer" - "$http_user_agent" - "$http_x_forwarded_for"';

  #设置日志默认存储目录
access_log logs/access.log main;
error_log logs/error.log;

说明:

$remote_addr, $http_x_forwarded_for(反向) 记录客户端IP地址
$remote_user 记录客户端用户名称
$request 记录请求的URL和HTTP协议
$status 记录请求状态
$body_bytes_sent 发送给客户端的字节数,不包括响应头的大小; 该变量与Apache模块mod_log_config里的“%B”参数兼容。
$bytes_sent 发送给客户端的总字节数。
$connection 连接的序列号。
$connection_requests 当前通过一个连接获得的请求数量。
$msec 日志写入时间。单位为秒,精度是毫秒。
$pipe 如果请求是通过HTTP流水线(pipelined)发送,pipe值为“p”,否则为“.”。
$http_referer 记录从哪个页面链接访问过来的
$http_user_agent 记录客户端浏览器相关信息
$request_length 请求的长度(包括请求行,请求头和请求正文)。
$request_time 请求处理时间,单位为秒,精度毫秒; 从读入客户端的第一个字节开始,直到把最后一个字符发送给客户端后进行日志写入为止。
$time_iso8601 ISO8601标准格式下的本地时间。
$time_local 通用日志格式下的本地时间。

如要根据不同站点设置不同日志存储目录,则在以下位置配置:

server {
listen ;
server_name m.test.cc; #不同站点设置不同的日志存储路径,可以使用变量
access_log logs/$server_name.log main; root "F:/test/public_html";
location / {
try_files $uri $uri/ /index.php?$query_string;
index index.html index.htm index.php;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

最新文章

  1. python多线程学习记录
  2. 基于bootstrap的后台二级垂直菜单[转]
  3. 系统中异常公共处理模块 in spring boot
  4. apache日志轮询技术
  5. cocos2dx之触摸事件
  6. .a静态库的注意事项
  7. C++类中的静态成员变量与静态成员函数
  8. C++指针初始化总结
  9. SQLite数据库框架ORMLite与GreenDao的简单比较
  10. SQL Server 2014 新特性:IO资源调控
  11. 机器学习之numpy库中常用的函数介绍(一)
  12. 初学者Web介绍一些前端开发中的基本概念用到的技术
  13. IT连创业系列:说说苹果商店AppStore上架App应用前后遇到的那些神坑
  14. python3安装pycurl
  15. Shell-cat url-list.txt | xargs wget -c
  16. gdb windbg and od use
  17. 37_Reverse3_digit_Integer
  18. mysql sql执行慢 分析过程
  19. Hadoop基础-配置历史服务器
  20. 在 Vue 项目中引入 tinymce 富文本编辑器

热门文章

  1. 1.初步认识JVM -- JVM序列
  2. Excel error 64-bit version of SSIS
  3. 11. Container With Most Water(装最多的水 双指针)
  4. Python:数字的格式化输出
  5. DB开发之oracle
  6. 异常来自HRESULT:0x80070422
  7. Tcp/Ip:Telnet指令
  8. Matlab绘图基础——用print函数批量保存图片到文件(Print figure or save to file)
  9. 面向对象之php多态
  10. 51nod 1179 最大的最大公约数 一种筛选的方法