在此推薦一款分析日志的工具,方便我們日常對於網站的訪問狀況有一個較為清晰的了解
一.安裝
官網: https://goaccess.io/download
源碼安裝:
1. wget http://tar.goaccess.io/goaccess-0.8.1.tar.gz 2. tar -xzvf goaccess-0.8.1.tar.gz 3. cd goaccess-0.8.1/ 4. ./configure --enable-geoip --enable-utf8 5. make && make install
軟件包管理器安裝:
//Debian/Ubuntu apt-get install goaccess //Centos/Fedora yum install goaccess //osx brew install goaccess
二. 使用
log_formats 選擇:
使用GoAccess生成html報告:
goaccess -f access.log -a > report.html
生成json報告:
goaccess -f access.log -a -d -o json > report.json
CSV:
goaccess -f access.log -o csv > report.csv
由於nginx會自動壓縮日志,以下命令可以直接分析壓縮后的日志:
zcat access.log.*.gz | goaccess
#或者
zcat -f access.log* | goaccess
支持各種管道:
sed -n '/11\/Dec\/2014/,$ p' access.log | goaccess -a
想分析下百度/google對你網站爬了些啥內容?Easy:
grep -E "(google|baidu)"access.log | goaccess -a
常見錯誤:
1)
2)生成文件發生錯誤
參考: http://www.cnblogs.com/taosim/articles/4225557.html