qq_41265012 2018-06-12 08:58 采纳率: 70%
浏览 2221
已采纳

nginx log_format main代码要放在哪里

图片说明
图片说明

图片说明

log_format main ‘$remote_addr $http_x_connecting_ip – $remote_user [$time_local] “$request” ‘

                  ‘$status $body_bytes_sent “$http_referer” ‘

                  ‘”$http_user_agent” $request_time “$upstream_http_content_type”‘;

这段代码要放在哪个位置

另外还需要做哪些配置

  • 写回答

3条回答 默认 最新

  • MadHades 2018-06-12 17:51
    关注

    http {
    include mime.types;
    default_type application/octet-stream;

    log_format  main '{"remoteaddr":"$remote_addr","hostname":"$host","clientip":"$http_x_forwarded_for","timestamp":"$time_local","theme":"$scheme","http_verb":"$request_method",'
                     '"http_request_url":"$document_uri","http_request_args":"$args","http_version":"$http_version","request_time":$request_time,'
                     '"upstream_response_time":"$upstream_response_time","upstream_response_length":"$upstream_response_length",'
                     '"upstream_host":"$upstream_addr","http_status":"$status","bytes_read":"$body_bytes_sent","refferrer":"$http_referer","agent":"$http_user_agent"}';
    
    }
    
    放在这里, http中
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?