一、Nginx自身的日志配置
$pid: Nginx worker process id
二、Nginx如何传递信息给应用程序
location / {
proxy_pass http://upstream;
set $req_id $pid.$msec.$remote_addr.$connection.$connection_requests;
proxy_set_header X-Request-Id $req_id;
}
然后在应用程序中,获取 request.headers.Get("X-Request-Id") 即可