Nginx日志配置(Ngx_http_log_module)

本文介绍了Nginx的 ngx_http_log_module 模块,用于定义日志格式并高效保存日志。讨论了如何指定日志格式,包括常见的Nginx内置变量,如客户端地址、响应码等。同时,讲解了日志文件缓存的配置,如`open_log_file_cache`指令的参数,如`max`、`inactive`、`valid`和`min_uses`,以提高日志处理性能。
摘要由CSDN通过智能技术生成

Ngx_http_log_module:定义日志格式,并且以指定的格式保存

Syntax access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition];
access_log off;
Default access_log logs/access.log combined;
Context http, server, location, if in location, limit_except
Syntax log_format name [escape=default|json] string …;
Default log_format combined “…”;
Context http
  • 指定日志格式:
#示例配置  
log_format compression '$remote_addr - $remote_user [$time_local] '
                       '"$request" $status $bytes_sent '
                       '"$http_referer" "$http_user_agent" "$gzip_ratio"';

access_log /spool/logs/nginx-access.log compres
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值