apache log格式设置

LogFormat 可以用的格式串有(转自:http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats):

Format StringDescription
%%The percent sign
%aRemote IP-address
%ALocal IP-address
%BSize of response in bytes, excluding HTTP headers.
%bSize of response in bytes, excluding HTTP headers. In CLF format, i.e. a '-' rather than a 0 when no bytes are sent.
%{Foobar}CThe contents of cookie Foobar in the request sent to the server. Only version 0 cookies are fully supported.
%DThe time taken to serve the request, in microseconds.
%{FOOBAR}eThe contents of the environment variable FOOBAR
%fFilename
%hRemote host
%HThe request protocol
%{Foobar}iThe 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.
%kNumber 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.
%lRemote logname (from identd, if supplied). This will return a dash unless mod_ident is present and IdentityCheck is set On.
%mThe request method
%{Foobar}nThe contents of note Foobar from another module.
%{Foobar}oThe contents of Foobar: header line(s) in the reply.
%pThe canonical port of the server serving the request
%{format}pThe canonical port of the server serving the request or the server's actual port or the client's actual port. Valid formats are canonicallocal, orremote.
%PThe process ID of the child that serviced the request.
%{format}PThe process ID or thread id of the child that serviced the request. Valid formats are pidtid, and hextidhextid requires APR 1.2.0 or higher.
%qThe query string (prepended with a ? if a query string exists, otherwise an empty string)
%rFirst line of request
%RThe handler generating the response (if any).
%sStatus. For requests that got internally redirected, this is the status of the *original* request --- %>s for the last.
%tTime the request was received (standard english format)
%{format}tThe time, in the form given by format, which should be in strftime(3) format. (potentially localized)
%TThe time taken to serve the request, in seconds.
%uRemote user (from auth; may be bogus if return status (%s) is 401)
%UThe URL path requested, not including any query string.
%vThe canonical ServerName of the server serving the request.
%VThe server name according to the UseCanonicalName setting.
%XConnection status when response is completed:
X =connection aborted before the response completed.
+ =connection may be kept alive after the response is sent.
- =connection will be closed after the response is sent.

(This directive was %c in late versions of Apache 1.3, but this conflicted with the historical ssl %{var}c syntax.)

%IBytes received, including request and headers, cannot be zero. You need to enable mod_logio to use this.
%OBytes sent, including headers, cannot be zero. You need to enable mod_logio to use this.

日志格式示例:

"%t [%r] %>s %h %a %v %D %b [%{User-Agent}i] [%{Referer}i --> %U]"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值