在使用该指令之前的注释中LogFormat
写道:
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
然后:
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
这些意味着什么以及我们为什么需要这些?
希望得到尽可能详细但简单的解释。
答案1
Apache 提到这些日志格式使用略微偏离慢性肝衰竭出于上述原因。我认为这没什么大不了的,因为它们非常相似,工具会解析它们。您可以将这些日志格式用于自定义日志,例如:
CustomLog logs/access_log common
这样,您就可以重复使用日志格式(例如虚拟主机的日志格式),而不必现场指定它们。以上是常见的预定义日志格式。您可以根据需要指定任意数量。