普通日志格式 common log format,CLF common大多数日志分析软件都支持这种格式
参考日志格式 referer log format referer记录客户访问站点的用户身份
代理日志格式 agent log format agent记录请求的用户代理
综合日志格式 combined log format combined结合以上三种日志信息
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent
Format String | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
%% | The percent sign | ||||||||||
%a | Remote IP-address | ||||||||||
%A | Local IP-address | ||||||||||
%B | Size of response in bytes, excluding HTTP headers. | ||||||||||
%b | Size of response in bytes, excluding HTTP headers. In CLF format, i.e. a '- ' rather than a 0 when no bytes are sent. | ||||||||||
%{Foobar}C | The contents of cookie Foobar in the request sent to the server. Only version 0 cookies are fully supported. | ||||||||||
%D | The time taken to serve the request, in microseconds. | ||||||||||
%{FOOBAR}e | The contents of the environment variable FOOBAR | ||||||||||
%f | Filename | ||||||||||
%h | Remote host | ||||||||||
%H | The request protocol | ||||||||||
%{Foobar}i | The contents of Foobar: header line(s) in the request sent to the server. Changes made by other modules (e.g. mod_headers ) affect this. If you're interested in what the request header was prior to when most modules would have modified it, use mod_setenvif to copy the header into an internal environment variable and log that value with the %{VARNAME}e described above. | ||||||||||
%k | Number of keepalive requests handled on this connection. Interesting if KeepAlive is being used, so that, for example, a '1' means the first keepalive request after the initial one, '2' the second, etc...; otherwise this is always 0 (indicating the initial request). Available in versions 2.2.11 and later. | ||||||||||
%l | Remote logname (from identd, if supplied). This will return a dash unless mod_ident is present and IdentityCheck is set On . | ||||||||||
%m | The request method | ||||||||||
%{Foobar}n | The contents of note Foobar from another module. | ||||||||||
%{Foobar}o | The contents of Foobar: header line(s) in the reply. | ||||||||||
%p | The canonical port of the server serving the request | ||||||||||
%{format}p | The canonical port of the server serving the request or the server's actual port or the client's actual port. Valid formats are canonical , local , or remote . | ||||||||||
%P | The process ID of the child that serviced the request. | ||||||||||
%{format}P | The process ID or thread id of the child that serviced the request. Valid formats are pid , tid , and hextid . hextid requires APR 1.2.0 or higher. | ||||||||||
%q | The query string (prepended with a ? if a query string exists, otherwise an empty string) | ||||||||||
%r | First line of request | ||||||||||
%R | The handler generating the response (if any). | ||||||||||
%s | Status. For requests that got internally redirected, this is the status of the *original* request --- %>s for the last. | ||||||||||
%t | Time the request was received (standard english format) | ||||||||||
%{format}t | The time, in the form given by format, which should be in an extended strftime(3) format (potentially localized). If the format starts with begin: (default) the time is taken at the beginning of the request processing. If it starts with end: it is the time when the log entry gets written, close to the end of the request processing. In addition to the formats supported by strftime(3) , the following format tokens are supported:
strftime(3) formatting in the same format string. You can use multiple %{format}t tokens instead. The extended strftime(3) tokens are available in 2.2.30 and later. | ||||||||||
%T | The time taken to serve the request, in seconds. | ||||||||||
%{UNIT}T | The time taken to serve the request, in a time unit given by UNIT . Valid units are ms for milliseconds, us for microseconds, and s for seconds. Using s gives the same result as %T without any format; using us gives the same result as %D . Combining %T with a unit is available in 2.2.30 and later. | ||||||||||
%u | Remote user (from auth; may be bogus if return status (%s ) is 401) | ||||||||||
%U | The URL path requested, not including any query string. | ||||||||||
%v | The canonical ServerName of the server serving the request. | ||||||||||
%V | The server name according to the UseCanonicalName setting. | ||||||||||
%X | Connection status when response is completed:
(This directive was | ||||||||||
%I | Bytes received, including request and headers, cannot be zero. You need to enable mod_logio to use this. | ||||||||||
%O | Bytes sent, including headers, cannot be zero. You need to enable mod_logio to use this. | ||||||||||
%{VARNAME}^ti | The contents of VARNAME: trailer line(s) in the request sent to the server. | ||||||||||
%{VARNAME}^to | The contents of VARNAME: trailer line(s) in the response sent from the server. |
ref:http://httpd.apache.org/docs/2.2/zh-cn/mod/mod_log_config.html