跳到主要内容

goaccess

brew install goaccess

goaccess access.log -o report.html --log-format=COMBINED
goaccess access.log -o report.html --log-format=COMBINED --real-time-html

LC_ALL=C LC_TIME=en_US.UTF-8 goaccess ac.log -p goaccess.conf -o report.html -a
namelog-format
NCSA Combined Log Format%h %^[%d:%t %^] "%r" %s %b "%R" "%u"
NCSA Combined Log Format with Virtual Host%v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
Common Log Format (CLF)%h %^[%d:%t %^] "%r" %s %b
Common Log Format (CLF) with Virtual Host%v:%^ %h %^[%d:%t %^] "%r" %s %b
W3C%d %t %h %^ %^ %^ %^ %r %^ %s %b %^ %^ %u %R
Squid native log format%^ %^ %^ %v %^: %x.%^ %~%L %h %^/%s %b %m %U
AWS / Amazon CloudFront (Download Distribution)%d\t%t\t%^\t%b\t%h\t%m\t%^\t%r\t%s\t%R\t%u\t%^
Google Cloud Storage"%x","%h",%^,%^,"%m","%U","%s",%^,"%b","%D",%^,"%R","%u"
AWS / Elastic Load Balancing%dT%t.%^ %^ %h:%^ %^ %T %^ %^ %^ %s %^ %b "%r" "%u"
AWSS3 / Amazon Simple Storage Service (S3)%^[%d:%t %^] %h %^"%r" %s %^ %b %^ %L %^ "%R" "%u"
Virtualmin Log Format with Virtual Host%h %^ %v %^[%d:%t %^] "%r" %s %b "%R" "%u"
Kubernetes Nginx Ingress Log Format%^ %^ [%h] %^ %^ [%d:%t %^] "%r" %s %b "%R" "%u" %^ %^ [%v] %^:%^ %^ %T %^ %^
namefor
COMBINEDCombined Log Format
VCOMBINEDCombined Log Format with Virtual Host
COMMONCommon Log Format
VCOMMONCommon Log Format with Virtual Host
W3CW3C Extended Log File Format
SQUIDNative Squid Log Format
CLOUDFRONTAmazon CloudFront Web Distribution
CLOUDSTORAGEGoogle Cloud Storage
AWSELBAmazon Elastic Load Balancing
AWSS3Amazon Simple Storage Service (S3)
AWSALBAmazon Application Load Balancer
CADDYCaddy's JSON Structured format
  • CADDY JSON Structured
    • {ts:"%x.%^",request:{remote_ip:"%h",proto:"%H",method:"%m",host:"%v",uri:"%U",headers:{"User-Agent":["%u","%^"]},tls:{cipher_suite:"%k",proto:"%K"}},duration:"%T",size:"%b",status:"%s",resp_headers:{"Content-Type":["%M;%^"]}}
specifierfor
%^忽略
%h
%ddate
%ttime
%rrequest
%Hprotocol
%sstatus code
%qquery string
%bresponse size
%RReferer
%uUser-Agent
%Tprocess time - seconds
%Dprocess time - ms
%Lprocess time - ms decimal number
%vserver name - virtual host
%euser id
%Ccache status
  • 至少需要 %h %d %r

Nginx

log_format combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';

log_format timed_combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time $pipe';

Nginx

time-format %H:%M:%S
date-format %d/%b/%Y
log-format %^ - %^ [%d:%t %^] "%r" %s %b "%R" "%u" %T "%h,%^"

Nginx with Cache & VHost

log_format full '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$host" $upstream_cache_status '
'$request_time';
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h - %^ [%d:%t %^] "%r" %s %b "%R" "%u" "%v" %C %T

FAQ

Token '25/Sep/2022' doesn't match specifier '%d'

LC_ALL=C LC_TIME=en_US.UTF-8 goaccess access.log -p goaccess.conf -o report.html

IPv4/6 is required

%h 未匹配