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条)

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch