Nginx.conf 中log日志的配置
- access_log 指令
语法:
access_log path [format [buffer=size [flush=time]]];
access_log path format gzip[=level] [buffer=size] [flush=time];
access_log syslog:server=address[,parameter=value] [format];
access_log off;
默认值: access_log logs/access.log combined;
配置段: http, server, location, if in location, limit_except
gzip 压缩等级。
buffer 设置内存缓存区大小。
flush 保存在缓存区中的最长时间。
不记录日志: access_log off;
使用默认 combined 格式记录日志: access_log logs/access.log 或 access_log logs/access.log combined;
- log_format 指令
语法:
log_format name string …;
默认值: log_format combined “…” ;
配置段: http
name 表示格式名称, string 表示等义的格式。 log_format 有一个默认的无需设置的 combined 日志格式,相当于
apache 的 combined 日志格式,如下所示:
log_format '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'