Logging to syslog
记录到syslog
The
error_log
and
access_log
directives support logging to syslog.
The following parameters configure logging to syslog:
error_log和access_log指令支持向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 “
unix:
” prefix.
If port is not specified, the UDP port 514 is used.
If a domain name resolves to several IP addresses, the first resolved
address is used.
用于定义syslog服务器地址。该地址可指定为域名或IP地址,并可选择端口,也可用"unix:
"指定UNIX域套接字路径。如果未指定端口,则使用UDP的514端口。如果域名解析到多个IP地址,则使用第一个解析到的地址。
facility=
string
-
Sets facility of syslog messages, as defined in
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
”.
Default is “local7
”.
RFC 3164定义了syslog的消息设备。设备可以是“kern
”, “user
”,“mail
”, “daemon
”,
“auth
”, “intern
”,
“lpr
”, “news
”, “uucp
”,
“clock
”, “authpriv
”,
“ftp
”, “ntp
”, “audit
”,
“alert
”, “cron
”,
“local0
”..“local7
”.
Default is “local7
”
severity=
string
-
Sets severity of syslog messages for
access_log,
as defined in
RFC 3164.
Possible values are the same as for the second parameter (level) of the
error_log directive.
Default is “
info
”.
根据RFC 3164的定义,设置access_log系统日志信息的严重程度。其值与error_log指令的第二个参数(级别)相同。默认值为"info
"。
Severity of error messages is determined by nginx, thus the parameter
is ignored in the error_log
directive.
错误信息的严重程度由nginx决定,因此在error_log
指令中忽略了该参数。
tag=
string
-
Sets the tag of syslog messages.
Default is “
nginx
”.
设置syslog消息的标记。默认为"nginx
"。
nohostname
-
Disables adding the “hostname” field into the syslog message header (1.9.7).
禁止在系统日志报文头中添加"hostname"字段(nginx版本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.
As part of our
commercial subscription
logging to syslog is available since version 1.5.3.
自1.7.1版起可向syslog发送日志。作为商业订阅的一部分,从1.5.3版起即可向syslog发送日志。