nginx-OpenShift吊舱中未应用日志格式
多亏了来自上的答案,我能够在OpenShift pod上成功运行Nginx。但是,我看不到此pod中的日志采用此配置文件中定义的格式nginx-OpenShift吊舱中未应用日志格式,nginx,logging,openshift,Nginx,Logging,Openshift,多亏了来自上的答案,我能够在OpenShift pod上成功运行Nginx。但是,我看不到此pod中的日志采用此配置文件中定义的格式 nginx.conf events { } http { log_format main '$time_iso8601 - $remote_addr - "$http_user_agent" - "$request" - $request_id ' '- $status - $body_bytes_sent - $request_time ';
nginx.conf
events { }
http {
log_format main '$time_iso8601 - $remote_addr - "$http_user_agent" - "$request" - $request_id '
'- $status - $body_bytes_sent - $request_time ';
upstream point1 {
server point1-os.point1-os.svc:8080;
}
upstream point2 {
server point2-os.point2-os.svc:8080;
}
server {
listen 8080;
location /point1/ {
proxy_set_header X-Request-Id $request_id;
proxy_pass http://point1/;
}
location /point2/ {
proxy_set_header X-Request-Id $request_id;
proxy_pass http://point2/;
}
}
}
相反,我看到的日志如下所示:
172.17.0.1 - - [30/Sep/2019:23:48:02 +0530] "POST /point2/processes HTTP/1.1" 200 51 "-" "PostmanRuntime/7.17.1"
172.17.0.1 - - [30/Sep/2019:23:52:37 +0530] "GET /point2/process/resource1 HTTP/1.1" 400 223 "-" "PostmanRuntime/7.17.1"
172.17.0.1 - - [30/Sep/2019:23:53:11 +0530] "DELETE /point2/process/resource1 HTTP/1.1" 200 58 "-" "PostmanRuntime/7.17.1"
172.17.0.1 - - [30/Sep/2019:23:53:15 +0530] "GET /point2/process/resource1 HTTP/1.1" 200 66 "-" "PostmanRuntime/7.17.1"
鉴于,预期的日志应按以下顺序排列:
- 时间戳
- 远程地址
- HTTP用户代理,例如
PostmanRuntime/7.17.1
- 请求动词,例如
,GET
等POST
- 请求Id-由Nginx自动注入-未看到且严重需要
- 地位
- 发送的字节数
- 请求时间
main
的log\u格式。您仍然需要将该格式应用于访问日志,类似于以下内容的内容应该可以工作
log_format main '$time_iso8601 - $remote_addr - "$http_user_agent" - "$request" - $request_id - $status - $body_bytes_sent - $request_time ';
access_log /var/log/nginx/access.log main;