Nginx日志配置和日志切割

Nginx 日志配置

日志使用用来进行数据统计、问题排错的重要手段。本文主要介绍 nginx 日志相关的配置如 access_log、log_format、log_not_found、rewrite_log、error_log 以及 Nginx 日志切割。

日志相关配置

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 logs/access.log combined;
配置段: http, server, location, if in location, limit_except
参数解释:

  • gzip:压缩等级。
  • buffer:设置内存缓存区大小。
  • flush:保存在缓存区中的最长时间。

log_fo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值