Nginx笔记总结九:Nginx日志配置
ngx_http_log_module用来定义请求日志格式
1. access_log指令
语法: access_log path [format [buffer=size [flush=time]]]
access_log path format gzi=[level] [buffer=size] [flush=time]
access_log syslog:server=address[,paramter=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 #好像没作用
2. log_format指令
语法:log_format name string ......
配置段:http
name 表示格式名称,string表示定义的格式
log_format combined '$remote_addr - $remote_user [$time_local]'
'"$request" $status $body_tytes_sent'
' $http_referer "$http_user_agent"'
log_format proxy '$http_x_forwarded_for - $remote_user [$time_local]'
'"$request" $status $body_bytes_sent'
' "$http_referer " " $http_user_agent"';
3. 日志格式允许包含的变量:
$remote_addr, $http_x_forwarded_for 记录客户端IP地址
$remote_user 记录客户端名称
$request 记录请求的URL和HTTP协议
$status 记录请求状态
$body_bytes_sent 发送给客户端的字节数,不包括响应头的大小
$bytes_sent 发送给客户端的总字节数
$connection 链接的序列号
$connection_requests 当前通过一个链接获得的请求数量
$msec 日志写入时间,单位为秒,精确是毫秒
$pipe 如果请求时通过http流水线发送,pipe值为p,否则为.
$http_referer 记录从那个页面链接访问过来的
$http_user_agent 记录客户端浏览器相关信息
$request_length 请求的长度
$request_time 请求处理时间,单位为秒,精确度毫秒
$time_iso8601 标准格式下的本地时间
$time_local 通用日志格式下的本地时间
4. open_log_file_cache指令
语法:open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time]
默认值:open_log_file_cache off;
配置段:http,server,location
max:最大文件描述符数量
inactive:存货时间,默认10s
min_uses:设置在inactive时间段中,日志文件最少使用多少次,该日志文件描述符记入缓存中,默认1次
valid:设置检查频率,默认60s
off:禁用
open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;
5. log_not_found指令
语法:log_not_found on | off
默认值:log_not_found on;
匹配段:http,server,location
是否在error_log中记录不存在的错误,默认on
6. log_subequest指令
语法:log_subrequest on | off;
默认值:log_subrequest off;
配置段:http,server,location
是否在access_log中记录子请求的访问日志,默认off
7. rewrite_log指令
由ngx_http_rewrite_module模块提供,用来记录重写日志
语法:rewrite_log on | off;
默认值 rewrite_log off;
配置段:http,server,location,if
启用时将error log中记录notice级别的重写日志
8. error_log指令
语法:error_log | stderr | syslog:server=address[,parameter=value [debug | info| notice| warn | error | crit | alert | emerg]]
默认值:error_log logs/error.log error;
配置段:main,http,server,location
配置错误日志
Nginx笔记总结九:Nginx日志配置的更多相关文章
- nginx启用TCP反向代理日志配置
Nginx使用TCP反向代理日志配置不同于http 修改nginx配置文档/usr/local/nginx/conf/nginx.conf 设置日志格式 stream { log_format pro ...
- Nginx实战(三) 日志配置与切割
访问日志主要记录客户端访问Nginx的每一个请求,格式可以自定义.通过访问日志,你可以得到用户地域来源.跳转来源.使用终端.某个URL访问量等相关信息. Nginx中访问日志相关指令主要有两条,一条是 ...
- Nginx笔记总结十七:nginx生成缩略图配置(http_image_filter_module)
编译: ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_realip_module-- ...
- Nginx笔记总结十:Nginx日志切割
1.Nginx日志切割 logrotate日志文件管理工具,通过cron程序定期执行,默认在cron默认程序的dayli目录下 [root@joker logrotate.d]# cat /etc/c ...
- Nginx笔记总结五:Nginx配置虚拟主机
upstream proxy1 { server ; } upstream proxy2 { server ; } server { listen ; server_name www1.dlab.co ...
- Nginx笔记总结六:Nginx location配置
语法规则:location [= | ~ | ~* | ^~] /uri/ {....} = 表示精确匹配 ^~ 表示uri以某个常规字符串开头 ~ 表示区分大小写的正则表达式 ~* 表示不区分大小写 ...
- springboot学习笔记:4.logback日志配置
springboot中日志组件推荐使用logback: 由于springboot内置了logback,所以可以直接在application.properties中配置:如果要功能丰富些,则配置下log ...
- Nginx笔记总结二:Nginx编译参数
-prefix= 安装路径-with-http_ssl_module ...
- Nginx笔记总结十三:nginx 正向代理
server { listen ; location / { resolver 202.106.0.20 202.106.119.116; resolver_timeout 30s; proxy_pa ...
随机推荐
- P2P平台疯狂爆雷后,你的生活受到影响了吗?
最近这段时间P2P爆雷的新闻和报道一直占据着各大财经和科技媒体的重要位置.而据网贷之家数据显示,截至2018年7月底,P2P网贷行业累计平台数量达到6385家(含停业及问题平台),其中问题平台累计为2 ...
- rabbitmq参考文档
英文文档:http://www.rabbitmq.com/getstarted.html 中文文档:http://rabbitmq.mr-ping.com/ rabbitmq重启,消费者恢复,解决消费 ...
- Linux中PATH、 LIBRARY_PATH、 LD_LIBRARY_PATH和ROS_PACKAGE_PATH
PATH 保存可执行文件程序路径,我们命令行中每一句能运行的命令都是系统先通过PATH来找到命令执行文件所在的位置,再运行这个命令. 实验:执行echo $PATH 能看到当前环境PATH都是配置了哪 ...
- StartDT AI Lab | 数据增强技术如何实现场景落地与业务增值?
有人说,「深度学习“等于”深度卷积神经网络算法模型+大规模数据+云端分布式算力」.也有人说,「能够在业内叱咤风云的AI都曾“身经百战”,经历过无数次的训练与试错」.以上都需要海量数据做依托,对于那些数 ...
- ubuntu下切换默认的python版本
Ubuntu系统自带python2.7(默认)和python3.5,所以不需要自己安装python.我们可以使用命令python -V或python3 -V来查看默认的python版本. 现在越来越多 ...
- CF1137E Train Car Selection(单调栈维护凸函数)
首先本题的关键是一次性加0操作只有第一个0是有用的.然后对于1 k操作,其实就是把之前的所有数删除.对于其他的情况,维护一次函数的和,将(i,a[i])看成平面上的一个点,用单调栈维护一下. #inc ...
- Equal Cut
Equal Cut 题目描述 Snuke has an integer sequence A of length N. He will make three cuts in A and divide ...
- vue中axios的post请求使用form表单格式发送数据
vue使用插件qs实现 (qs 是一个增加了一些安全性的查询字符串解析和序列化字符串的库.) 在jquery中的ajax的方法已将此封装,所以不需要再次序列化 1. 安装 在项目中使用命令行工具输 ...
- Unittest - Python 使用总结
Unittest - Python 使用总结 批量执行 一.UnitTest TestSuite 控制用例执行的顺序 UnitTest 框架默认 main() 方法根据 ASCII 码的顺序加载测试用 ...
- Django模型迁移提示版本不匹配解决办法
Django迁移模型时提示django.core.exceptions.ImproperlyConfigured:mysqlclient 1.3.7 or newer is required; you ...