Nginx中ngx_http_log_module模块

指定⽇日志格式记录请求
指令:
 access_log
设置缓冲⽇日志写⼊入的路路径,格式和配置
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
 log_format
指定⽇日志格式
Syntax: log_format name
[escape=default|json|none] string
...;
Default: log_format combined "...";
Context: http
变量量:
$remote_addr # 客户端地址
$remote_user # 提供基本身份验证的⽤用户

$time_local # 通⽤用⽇日志格式的本地时间
$request # 请求的URL
$status # 响应的状态码
$bytes_sent # 发送到客户端的字节数
$http_referer # 从哪个⻚页⾯面跳转到当前⻚页
⾯面
$http_user_agent # ⽤用户代理理(浏览器器的
名称)
$gzip_ratio # 压缩⽐比
$connection # 连接序列列号
$connection_requests # 通过连接发出的
当前请求数
$msec # 以秒为单位的时间,⽇日志写⼊入时的
分辨率为毫秒
$request_length
$request_time # 以毫秒为单位请求处理理时
间(以秒为单位); 从客户端读取第⼀一个字节
之间经过的时间,并将最后⼀一个字节发送到
客户端后的⽇日志写⼊入
http{
log_format compression '$remote_
addr - $remote_user [$time_local] '
'"$reques
t" $status $bytes_sent '
'"$http_r
eferer" "$http_user_agent" "$gzip_ra
tio"';
}
access_log /data/logs/nginx-acce
ss.log compression buffer=32k;
PS:”compression”只是⼀一个名称,写成其
他的也可以。但是 access_log 调⽤用时的名字
要和 log_format 定义时的名字保持⼀一致。注
意: log_format 只能⽤用在 http 语句句块中
 open_log_file_cache
定义⼀一个缓存,⽤用于存储名称中包含变量量的常⽤用⽇日
志的⽂文件描述符
Syntax: open_log_file_cache max=N
[inactive=time] [min_uses=N]
[valid=time];
open_log_file_cache off;
Default: open_log_file_cache off;
Context: http, server, location
该指令具有以下参数:
max # 缓存的最⼤大⽂文件描述符数量量
min_uses # 在inactive指定的时⻓长内访问⼤大
于等于此值⽅方可被当作活动项
inactive # ⾮非活动时⻓长
valid # 验证缓存中各缓存项是否为活动项
的时间间隔
off # 禁⽤用缓存

转载于:https://www.cnblogs.com/momenglin/p/11024925.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值