官网说明
https://nginx.org/en/docs/http/ngx_http_log_module.html
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, limi
log_format
Syntax: log_format name [escape=default|json|none] string ...; Default: log_format combined "..."; Context: 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
日志
Example Configuration
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;
可以使用 https://nginx.org/en/docs/varindex.html 内置的变量。
GoAccess实现可视化并实时监控access日志
https://goaccess.io/get-started
第一步
[root@VM-0-7-centos ~]# goaccess access.log -o ../html/report.html --real-time-html --time-format='%H:%M:%s' --date-format='%d/%b/%Y' --log-format=COMBINED Websocket server ready to accept new client connections
第二步
第三部