Logging to syslog登录到系统日志
The error_log and access_log directives support logging to syslog. error_log和access_log指令支持记录到syslog。The following parameters configure logging to syslog:以下参数将日志记录配置为syslog:
server=
address
Defines the address of a syslog server.定义系统日志服务器的地址。The address can be specified as a domain name or IP address, with an optional port, or as a UNIX-domain socket path specified after the “该地址可以指定为域名或IP地址,带有可选端口,或者在“unix:
” prefix.unix:
”前缀后指定为UNIX域套接字路径。If port is not specified, the UDP port 514 is used.如果未指定端口,则使用UDP端口514。If a domain name resolves to several IP addresses, the first resolved address is used.如果域名解析为多个IP地址,则使用第一个解析的地址。facility=
string
Sets facility of syslog messages, as defined in RFC 3164.设置系统日志消息的功能,如RFC 3164中所定义。Facility can be one of “设施可以是“kern
”, “user
”, “mail
”, “daemon
”, “auth
”, “intern
”, “lpr
”, “news
”, “uucp
”, “clock
”, “authpriv
”, “ftp
”, “ntp
”, “audit
”, “alert
”, “cron
”, “local0
”..“local7
”.kern
”、“user
”、“mail
”、“daemon
”、“auth
”、“intern
”、“lpr
”、“news
”、“uucp
”、“clock
”、“authpriv
”、“ftp
”、“ntp
”、“audit
”、“alert
”、“cron
”、“local0
”、“local7
”中的一个。Default is “默认值为“local7
”.local7
”。severity=
string
Sets severity of syslog messages for access_log, as defined in RFC 3164.设置access_log的系统日志消息的严重性,如RFC 3164中所定义。Possible values are the same as for the second parameter (level) of the error_log directive.可能的值与error_log指令的第二个参数(级别)的值相同。Default is “默认值为“info
”.info
”。Severity of error messages is determined by nginx, thus the parameter is ignored in the错误消息的严重性由nginx确定,因此在error_log
directive.error_log
指令中忽略该参数。tag=
string
Sets the tag of syslog messages.设置系统日志消息的标记。Default is “默认值为“nginx
”.nginx
”。nohostname
Disables adding the “hostname” field into the syslog message header (1.9.7).禁止将“主机名”字段添加到syslog消息头中(1.9.7)。
Example syslog configuration:系统日志配置示例:
error_log syslog:server=192.168.1.1 debug;
access_log syslog:server=unix:/var/log/nginx.sock,nohostname;
access_log syslog:server=[2001:db8::1]:12345,facility=local7,tag=nginx,severity=info combined;
Logging to syslog is available since version 1.7.1.从版本1.7.1开始,可以使用syslog日志记录。As part of our commercial subscription logging to syslog is available since version 1.5.3.作为我们商业订阅的一部分,syslog的日志记录从1.5.3版开始提供。