【问题标题】:How can I log grpc status in Nginx access log?如何在 Nginx 访问日志中记录 grpc 状态?
【发布时间】:2020-12-14 02:17:34
【问题描述】:

我想在 Nginx 访问日志中记录 grpc 状态码 试过了

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $http_grpc_status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

但不工作的 Nginx 只会记录 http 状态码而不是 grpc_status

【问题讨论】:

    标签: nginx grpc http2


    【解决方案1】:

    * 你是什么意思? GRPCS 状态?

    你已经尝试过了

    • 制作文件日志:

      • nano /var/log/nginx/[filelog].log
    • [关闭并保存]

    • 在 .conf 中试试这个

    输出服务器指令

    log_format prog3 '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" $server_port $scheme';

    在服务器指令中

    服务器{
    …… access_log /var/log/nginx/[filelog].log prog3;

    • 并以调试模式执行nginx
      • 停止 nginx
      • /etc/init.d/nginx 停止
    • 运行 nginx-debug
      • /etc/init.d/nginx-debug start

    【讨论】:

      猜你喜欢
      • 2013-10-16
      • 1970-01-01
      • 1970-01-01
      • 2012-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-25
      • 1970-01-01
      相关资源
      最近更新 更多