Apache Log配置

 

  • 常用配置

LoadModule log_config_module modules/mod_log_config.so

LogLevel warn
 
<IfModule log_config_module>

     LogFormat "%h %l %u %t /"%r/" %>s %b /"%{Referer}i/" /"%{User-Agent}i/" /"%{Cookie}i/""

    <FilesMatch "/.(ico|gif|jpg|png|bmp|swf|css|js)">
      SetEnv IMAG 1
    </FilesMatch>
    CustomLog "logs/access_log" combined env=!IMAG
</IfModule>

  • Log配置项说明:

 %...a:          Remote IP-address
 %...A:          Local IP-address
 %...B:          Bytes sent, excluding HTTP headers.
 %...b:          Bytes sent, excluding HTTP headers. In CLF format  i.e. a '-' rather than a 0 when no bytes are sent.
 %...c:          Connection status when response was 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.
 %...{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.
 %...l:          Remote logname (from identd, if supplied)
 %...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
 %...P:          The process ID of the child that serviced the request.
 %...q       The query string (prepended with a ? if a query string exists, otherwise an empty string)
 %...r:          First line of request
 %...s:          Status.  For requests that got internally redirected, this is the status of the *original* request --- %...>s for the last.
 %...t:          Time, in common log format time format (standard english format)
 %...{format}t:  The time, in the form given by format, which should be in strftime(3) format. (potentially localized)
 %...T:          The time taken to serve the request, in seconds.
 %...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.
 

日期格式
 %Y-%m-%d %H:%M:%S
 %A - full weekday name (localized)
 %a - 3-character weekday name (localized)
 %B - full month name (localized)
 %b - 3-character month name (localized)
 %c - date and time (localized)
 %d - 2-digit day of month
 %H - 2-digit hour (24 hour clock)
 %I - 2-digit hour (12 hour clock)
 %j - 3-digit day of year
 %M - 2-digit minute
 %m - 2-digit month
 %p - am/pm of 12 hour clock (localized)
 %S - 2-digit second
 %U - 2-digit week of year (Sunday first day of week)
 %W - 2-digit week of year (Monday first day of week)
 %w - 1-digit weekday (Sunday first day of week)
 %X - time (localized)
 %x - date (localized)
 %Y - 4-digit year
 %y - 2-digit year
 %Z - time zone name
 %% - literal `%'
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值