zoukankan      html  css  js  c++  java
  • nginx日志

    1.语法:

    Syntax:	log_format name [escape=default|json|none] string ...;
    Default:	log_format combined "...";
    Context:	http    //只能定义在http标签里面,server,location 
    

    2.默认日志格式:

    #vim /usr/local/nginx/conf/nginx.conf 
    http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log logs/access.log main;
    error_log logs/error.log;
    }
    注意:如果定义在server里面只对当前server生效,如果定义在http内server外对所有的server生效
    

    3.nginx日志变量:

    $remote_addr				//表示客户端地址
    $remote_user				//http客户端请求nginx认证⽤户名
    $time_local				//Nginx的时间
    $request					//Request请求⾏,GET等⽅法http协议版本
    $status					//respoence返回状态码
    $body_bytes_sent			//从服务端响应给客户端body信息⼤⼩
    $http_referer				//http上⼀级页⾯,防盗链、⽤户⾏为分析
    $http_user_agent			//http头部信息,	客户端访问设备
    $http_x_forwarded_for		//http请求携带的http信息				  
    

    4.验证:

    #nginx -t
    #nginx -s reload 
    # tail -1  /usr/local/nginx/logs/access.log 
    192.168.1.252 - - [17/May/2018:16:33:05 +0800] "GET /favicon.ico HTTP/1.1" 404 539 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0" "-"
    
  • 相关阅读:
    poj 3666 Making the Grade
    poj 3186 Treats for the Cows (区间dp)
    hdu 1074 Doing Homework(状压)
    CodeForces 489C Given Length and Sum of Digits...
    CodeForces 163A Substring and Subsequence
    CodeForces 366C Dima and Salad
    CodeForces 180C Letter
    CodeForces
    hdu 2859 Phalanx
    socket接收大数据流
  • 原文地址:https://www.cnblogs.com/lovelinux199075/p/9051861.html
Copyright © 2011-2022 走看看