zoukankan      html  css  js  c++  java
  • 设置Nginx日志

    在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       80;
        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:9000;
            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;
        }
    }
  • 相关阅读:
    Eclipse打jar包的方法
    Eclipse中SVN插件的安装
    无法远程访问 MySql Server
    TCP(Socket基础编程)
    安装淘宝镜像cnpm时出现问题及解决方案
    搭建vue脚手架---vue-cli
    padding和margin设置成百分比
    响应式布局
    响应式网页:用em,rem设置网页字体大小自适应
    url两次编码
  • 原文地址:https://www.cnblogs.com/pengyunjing/p/9229894.html
Copyright © 2011-2022 走看看