文章目录
- 官网说明
- access_log
- log_format
- open_log_file_cache
- 日志
- GoAccess实现可视化并实时监控access日志
官网说明
https://nginx.org/en/docs/http/ngx_http_log_module.html
access_log
代码语言:javascript复制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
代码语言:javascript复制Syntax: log_format name [escape=default|json|none] string ...;
Default:
log_format combined "...";
Context: http
open_log_file_cache
代码语言:javascript复制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
代码语言:javascript复制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/
https://goaccess.io/get-started
第一步
代码语言:javascript复制[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
第二步
第三部