goaccess是一款NGINX/APACHE2日志文件分析工具。
它可以读取.log
文件内容,并解析以图标的形式显示网站访问信息。
安装
1
| sudo apt install goaccess
|
配置
我的NGINX日志格式为
1
| log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" ';
|
编辑默认配置文件/etc/goaccess/goaccess.conf
取消注释或者添加配置项
1 2 3 4 5
| time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
|
其他根据需要设置
使用
先准备access.log文件,我的是57MB
执行命令
1 2 3
| goaccess -f ./access.log -p /etc/goaccess/goaccess.conf -a > 1.html [PARSING ./access.log] {218,843} @ {109,421/s} Cleaning up resources...
|
输入为当前目录的access.log文件,格式为默认的conf文件,输出结果至1.html中
输出结果为876KB
打开后可以看到详细信息
