Nginx 日志配置
0x00 前言
日志使用用来进行数据统计、问题排错的重要手段。本文主要介绍 nginx 日志相关的配置如 access_log、log_format、log_not_found、rewrite_log、error_log 以及 Nginx 日志切割。
0x01 日志相关配置
nginx日志相关涉及的配置有:access_log:访问日志;log_format:日志格式;rewrite_log:重定向日志;error_log:错误日志;
nginx 具备非常灵活的日志记录模式,每个级别的配置可以有各自独立的访问日志。日志格式通过 log_format 命令来定义。
· 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;
使用默认 combined 格式记录日志:access_log logs/access.log 或 access_log