What is the default apache2 log format and where is defined such default?
Solution 1
It is clearly stated in the documetation for the TransferLog statement:
This directive has exactly the same arguments and effect as the CustomLog directive, with the exception that it does not allow the log format to be specified explicitly or for conditional logging of requests. Instead, the log format is determined by the most recently specified LogFormat directive which does not define a nickname. Common Log Format is used if no other format has been specified.
Go on to the LogFormat statement:
Default: LogFormat "%h %l %u %t \"%r\" %>s %b"
So if a TransferLog
statement is given without any LogFormat
statement the output format is as described above.
If also the TransferLog
statment is missing no access log is written.
Solution 2
For Ubuntu 16.04, you can find the global configuration file here:
/etc/apache2/apache2.conf
Therein it defines some LogFormat
directives.
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
The out-of-the-box virtual host configuration file is here:
/etc/apache2/sites-available/000-default.conf
And inside you will find that it declares:
CustomLog ${APACHE_LOG_DIR}/access.log combined
The combined
alias refers to the second LogFormat
in the aforementioned global config:
"%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\""
Solution 3
Default LogFormat is indeed really
Default: LogFormat "%h %l %u %t \"%r\" %>s %b"
But the log format apache uses by default (on Debian distro at least) is:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I review (a fast reading) Apache Module mod_log_config and can't figure out what is the apache2 default log format and where is defined it. Any idea?
Note that what is on
/etc/apache2/conf.d/other-vhosts-access-log
is not a default option but a global option.
-
user785287 about 11 yearsThanks, but still can't read anything about TransferLog default, I mean, are you saying that if no CustomLog is specified, the TransferLog directive is in charge even it is not specified? If that is the case, where do you read that? cos TransferLog hasn't a default section defined. Thanks again.
-
H.-Dirk Schmitt about 11 yearsIf no TransferLog is defined, it is not written.
-
Jeff Puckett almost 8 yearsThis has changed ever so slightly for Ubuntu 16.04 from
%b
"Size of response in bytes, excluding HTTP headers. In CLF format, i.e. a '-' rather than a 0 when no bytes are sent." to now%O
"Bytes sent, including headers. May be zero in rare cases such as when a request is aborted before a response is sent. You need to enable mod_logio to use this."