我想解析我所有的Nginx日志(你可以在这里看到):
ls /var/log/Nginx/
access.log access.log.21.gz error.log.1 error.log.22.gz
access.log.1 access.log.22.gz error.log.10.gz error.log.23.gz
access.log.10.gz access.log.23.gz error.log.11.gz error.log.24.gz
access.log.11.gz access.log.24.gz error.log.12.gz error.log.2.gz
access.log.12.gz access.log.2.gz error.log.13.gz error.log.3.gz
access.log.13.gz access.log.3.gz error.log.14.gz error.log.4.gz
access.log.14.gz access.log.4.gz error.log.15.gz error.log.5.gz
access.log.15.gz access.log.5.gz error.log.16.gz error.log.6.gz
access.log.16.gz access.log.6.gz error.log.17.gz error.log.7.gz
access.log.17.gz access.log.7.gz error.log.18.gz error.log.8.gz
access.log.18.gz access.log.8.gz error.log.19.gz error.log.9.gz
access.log.19.gz access.log.9.gz error.log.20.gz
access.log.20.gz error.log error.log.21.gz
但我不知道该怎么做.首先,似乎goaccess无法解析.gz文件.
解析这些日志中包含的所有信息的最佳方法是什么?
最佳答案
引用man page并假设您有一个组合日志格式:
If we would like to process all access.log.*.gz we can do one of the following:
# zcat -f access.log* | goaccess --log-format=COMBINED
要么
# zcat access.log.*.gz | goaccess --log-format=COMBINED
在Mac OS X上,使用gunzip -c而不是zcat.