日志格式:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

分别定义了两种日志格式 combined 和 common。

日志格式详细说明:

%a remote_ip
%A local_ip
%B size
%b size
%D time_taken_ms
%f filename
%h remote_host
%H protocol
%l ident
%m method
%p port
%P pid
"%q" url_query
"%r" request
%s status
%>s status
%t time
%T time_taken
%u remote_user
%U url_stem
%v server_name
%V canonical_name
%I bytes_received
%O bytes_sent
"%{User-Agent}i" user_agent
"%{Referer}i" referer

网站日志示例:

127.0.0.1 - - [05/Aug/2023:13:31:53 +0800] "GET /favicon.ico HTTP/2.0" 404 548 "
http:\/\/localhost/referer.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"

127.0.0.1 远程主机IP

- 身份

- 远程用户

[05/Aug/2023:13:31:53 +0800] 时间

“GET /favicon.ico HTTP/1.1” 请求方式和路径及HTTP的版本号

404 请求状态

548 请求字节大小

"http://localhost/referer.html" 来源页面

"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" 用户代理信息(浏览器、系统等)

原文链接:https://www.cnblogs.com/hswangnux/p/6984282.html