Nginx日志分析

#####安装goaccess

1
# tar.gz安装
配置goaccess
1
shell> vi ~/.goaccessrc # 添加如下内容
.goaccessrc
1
2
3
time-format %T
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

Nginx日志格式

1
2
log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
日志文件分析
1
shell> goaccess -f FILE.log > FILE.html