Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

logs except for the error_log (by default, this is just the access_log)
are generated in a format specified by the CustomLog and LogFormat


directives, which appear in your apache2.conf file.


A new log format can be defined with the LogFormat directive:


Click here to view code image
LogFormat "%h %l %u %t \"%r\" %>s %b" common


The common log format is a good starting place for creating your own custom
log formats. Note that most of the available log analysis tools assume that
you’re using the common log format or the combined log format, both of
which are defined in the default configuration files.


The following variables are available for LogFormat statements:


%a—Remote   IP  address.
%A—Local IP address.
%b—Bytes sent, excluding HTTP headers. This is shown in Apache’s
Combined Log Format (CLF). For a request without any data content, a


  • is shown instead of 0.
    %B—Bytes sent, excluding HTTP headers.
    %{VARIABLE}e—The contents of the environment variable.
    %f—The filename of the output log.
    %h—Remote host.
    %H—Request protocol.
    %{HEADER}i—The contents of HEADER; header lines in the request sent
    to the server.
    %l—Remote log name (from identd, if supplied).
    %m—Request method.
    %{NOTE}n—The contents of NOTE from another module.
    %{HEADER}o—The contents of HEADER; header lines in the reply.
    %p—The canonical port of the server serving the request.
    %P—The PID of the child that serviced the request.
    %q—The contents of the query string, prepended with a ? character. If
    there’s no query string, this evaluates to an empty string.

Free download pdf