nginx 常用模块整理
1、 log_format name string ...;string可以使用nginx核心模块及其它模块内嵌的变量
2、 access_log path ] ];
access_log off;
访问日志文件路径,格式及相关的缓冲的配置
buffer=size
flush=time
示例
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 compression buffer=32k;
json格式日志示例;log_format json '{"@timestamp":"$time_iso8601",'
'"client_ip":"$remote_addr",'
'"size":$body_bytes_sent,'
'"responsetime":$request_time,'
'"upstreamtime":"$upstream_response_time",'
'"upstreamhost":"$upstream_addr",'
'"http_host":"$host",'
'"method":"$request_method",'
'"request_uri":"$request_uri",'
'"xff":"$http_x_forwarded_for",'
'"referrer":"$http_referer",'
'"agent":"$http_user_agent",'
'"status":"$status"}';
3、 open_log_file_cache max=N ;
open_log_file_cache off;
缓存各日志文件相关的元数据信息
max:缓存的最大文件描述符数量
min_uses:在inactive指定的时长内访问大于等于此值方可被当作活动项
inactive:非活动时长
valid:验正缓存中各缓存项是否为活动项的时间间隔
例: open_log_file_cache max=1000 inactive=20svalid=1m;
页:
[1]