Apache HTTP Server Version 1.3Module mod_log_config
This module is contained in the Summary
Three directives are provided by this module: Compatibility notes
Log File FormatsUnless told otherwise with LogFormat the log files created by TransferLog will be in standard "Common Log Format" (CLF). The contents of each line in a CLF file are explained below. Alternatively, the log file can be customized (and if multiple log files are used, each can have a different format). Custom formats are set withLogFormat and CustomLog.
Common Log FormatThe Common Log Format (CLF) file contains a separate line for each request. A line is composed of several tokens separated by spaces:host ident authuser date request status bytesIf a token does not have a value then it is represented by a hyphen (-). The meanings and values of these tokens are as follows:
Custom Log FormatsThe format argument to theLogFormat and
CustomLog is a string. This string is logged to the log
file for each request. It can contain literal characters copied into
the log files, and `%' directives which are replaced in the log file
by the values as follows:
%...b: Bytes sent, excluding HTTP headers.
%...f: Filename
%...{FOOBAR}e: The contents of the environment variable FOOBAR
%...h: Remote host
%...a: Remote IP-address
%...A: Local IP-address
%...{Foobar}i: The contents of Foobar: header line(s) in the request
sent to the server.
%...l: Remote logname (from identd, if supplied)
%...{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.
%...r: First line of request
%...s: Status. For requests that got internally redirected, this
is 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 localised)
%...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.
%...v: The canonical ServerName of the server serving the request.
%...V: The server name according to the UseCanonicalName setting.
The `...' can be nothing at all (e.g., "%h %u %r %s %b"), or it can
indicate conditions for inclusion of the item (which will cause it
to be replaced with `-' if the condition is not met). Note that
there is no escaping performed on the strings from %r, %...i and
%...o; some with long memories may remember that I thought this was
a bad idea, once upon a time, and I'm still not comfortable with
it, but it is difficult to see how to `do the right thing' with all
of `%..i', unless we URL-escape everything and break with CLF.
The forms of condition are a list of HTTP status codes, which may or may not be preceded by `!'. Thus, `%400,501{User-agent}i' logs User-agent: on 400 errors and 501 errors (Bad Request, Not Implemented) only; `%!200,304,302{Referer}i' logs Referer: on all requests which did not return some sort of normal status.
Note that the common log format is defined by the string
Note that the canonical ServerName
and Port of the server serving the request
are used for Using Multiple Log FilesTheTransferLog and CustomLog directives can
be given more than once to log requests to multiple log files. Each
request will be logged to all the log files defined by either of these
directives.
Use with Virtual HostsIf a <VirtualHost> section does not contain any TransferLog or CustomLog directives, the logs defined for the main server will be used. If it does contain one or more of these directives, requests serviced by this virtual host will only be logged in the log files defined within its definition, not in any of the main server's log files. See the examples below.
Security ConsiderationsSee the security tips document for details on why your security could be compromised if the directory where logfiles are stored is writable by anyone other than the user that starts the server.
DirectivesCookieLogSyntax: CookieLog filenameContext: server config, virtual host Module: mod_cookies Compatibility: Only available in Apache 1.2 and above The CookieLog directive sets the filename for logging of cookies. The filename is relative to the ServerRoot. This directive is included only for compatibility with mod_cookies, and is deprecated.
CustomLogSyntax: CustomLog file-pipe format-or-nicknameContext: server config, virtual host Status: Base Compatibility: Nickname only available in Apache 1.3 or later Module: mod_log_config The first argument is the filename to which log records should be written. This is used exactly like the argument to TransferLog; that is, it is either a full path or relative to the current server root. The format argument specifies a format for each line of the log file. The options available for the format are exactly the same as for the argument of the LogFormat directive. If the format includes any spaces (which it will do in almost all cases) it should be enclosed in double quotes. Instead of an actual format string, you can use a format nickname defined with the LogFormat directive. CustomLog (conditional)Syntax: CustomLog file-pipe format-or-nickname env=[!]environment-variableContext: server config, virtual host Status: Base Compatibility: Only available in Apache 1.3.5 or later Module: mod_log_config The behaviour of this form of the CustomLog directive is almost identical to the standard CustomLog
directive. The difference is that the 'env=' clause controls
whether a particular request will be logged in the specified file or
not. If the specified environment variable is set for the
request (or is not set, in the case of a 'env=!name'
clause), then the request will be logged.
Environment variables can be set on a per-request basis using the mod_setenvif and/or mod_rewrite modules. For example, if you don't want to record requests for all GIF images on your server in a separate logfile but not your main log, you can use:
SetEnvIf Request_URI \.gif$ gif-image
CustomLog gif-requests.log common env=gif-image
CustomLog nongif-requests.log common env=!gif-image
LogFormatSyntax: LogFormat format [nickname]Default: LogFormat "%h %l %u %t \"%r\"
%s %b"Context: server config, virtual host Status: Base Compatibility: Nickname only available in Apache 1.3 or later Module: mod_log_config This sets the format of the default logfile named by the TransferLog directive . See the section on Custom Log Formats for details on the format arguments. If you include a nickname for the format on the directive line, you can use it in other LogFormat and CustomLog directives rather than repeating the entire format string. A LogFormat directive which defines a nickname does nothing else -- that is, it only defines the nickname, it doesn't actually apply the format and make it the default. TransferLogSyntax: TransferLog file-pipeDefault: none Context: server config, virtual host Status: Base Module: mod_log_config The TransferLog directive adds a log file in the format defined by the most recent LogFormat directive, or Common Log Format if no other default format has been specified. File-pipe is one of
Apache HTTP Server Version 1.3 |