apache log

piaoling  2012-09-24 10:32:46
  • 常用配置

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 `%'
 


from:http://blog.csdn.net/airobot008/article/details/4767111

类别 :  apache(12)  |  浏览(4768)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: