nginx使用syslog前置数据来访问日志

使用以下格式和访问日志configuration:

log_format syslog '{"hi2u":true,"request_time":"$request_time","@timestamp":"$time_iso8601", "request_id":"$http_x_request_id", "token":"$token"}'; access_log syslog:server=localhost:9000 syslog; 

使用netcat时,我在端口9000上收到此消息:

<190> Aug 29 06:17:03 user-all-series nginx {“hi2u”:true,“request_time”:“0.000”,“@ timestamp”:“2017-08-29T06:17:03-07: 00“,”request_id“:” – “,”token“:”abcdef123456789“}

如果我看一下nginx源代码,看看这里添加的头是什么样的:

https://github.com/nginx/nginx/blob/master/src/http/modules/ngx_http_log_module.c#L360

任何人都知道一种方法来禁用标题,所以只是log_format显示? 我认为这可能只是一个系统日志格式的规范,我是无知的:)

我注释了这一行,这是我期望的行为:)

 if (log[l].syslog_peer) { // p = ngx_syslog_add_header(log[l].syslog_peer, line); } 

Alexy的另一个礼貌。 在这里添加它,让人们看到它:

这是系统日志协议的PRI部分tools.ietf.org/html/rfc3164#section-4.1.1