apache 日志格式

apache 日志格式和目录通常在配置文件 /etc/apache2/httpd.conf 中。

日志格式:

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

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

声明使用了 combined 这种日志格式和写入的文件名。

  1. CustomLog "/var/log/apache2/access_log" combined

日志样例:

  1. 192.168.1.2 - - [02/Feb/2016:17:44:13 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "http://localhost/x1.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36"

apache 日志格式详细说明:

  1. %a remote_ip
  2. %A local_ip
  3. %B size
  4. %b size
  5. %D time_taken_ms
  6. %f filename
  7. %h remote_host
  8. %H protocol
  9. %l ident
  10. %m method
  11. %p port
  12. %P pid
  13. "%q" url_query
  14. "%r" request
  15. %s status
  16. %>s status
  17. %t time
  18. %T time_taken
  19. %u remote_user
  20. %U url_stem
  21. %v server_name
  22. %V canonical_name
  23. %I bytes_received
  24. %O bytes_sent
  25. "%{User-Agent}i" user_agent
  26. "%{Referer}i" referer
posted @ 2017-06-11 09:10  94007  阅读(881)  评论(0)    收藏  举报
野渡无人舟自横