|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
vlink="#000080" alink="#FF0000">
Apache HTTP Server Version 1.3Module mod_log_configThis module provides for logging of the requests made to the server, using the Common Log Format or a user-specified format. Status: Base SummaryThis module provides for flexible logging of client requests. Logs are written in a customizable format, and may be written directly to a file, or to an external program. Conditional logging is provided so that individual requests may be included or excluded from the logs based on characteristics of the request. Three directives are provided by this module:
See also: Apache Log Files. DirectivesCustom Log FormatsThe format argument to the The characteristics of the request itself are logged by placing "%" directives in the format string, which are replaced in the log file by the values as follows: %...a: Remote IP-address %...A: Local IP-address %...B: Bytes sent, excluding HTTP headers. %...b: Bytes sent, excluding HTTP headers. In CLF format i.e. a '-' rather than a 0 when no bytes are sent. %...c: Connection status when response is completed. 'X' = connection aborted before the response completed. '+' = connection may be kept alive after the response is sent. '-' = connection will be closed after the response is sent. %...{FOOBAR}e: The contents of the environment variable FOOBAR %...f: Filename %...h: Remote host %...H The request protocol %...{Foobar}i: The contents of Foobar: header line(s) in the request sent to the server. %...l: Remote logname (from identd, if supplied) %...m The request method %...{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. %...q The query string (prepended with a ? if a query string exists, otherwise an empty string) %...r: First line of request %...s: Status. For requests that got internally redirected, this is the 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 localized) %...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, not including any query string. %...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., Note that there is no escaping performed on the strings from %...r, %...i and %...o. This is mainly to comply with the requirements of the Common Log Format. This implies that clients can insert control characters into the log, so care should be taken when dealing with raw log files. Some commonly used log format strings are:
Note that the canonical ServerName and Port of the server serving the
request are used for 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. Compatibility notes
CookieLog directiveSyntax: CookieLog
filename 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. CustomLog directiveSyntax: CustomLog
file|pipe format|nickname
[env=[!]environment-variable] The The first argument, which specifies the location to which the logs will be written, can take on one of the following two types of values:
The second argument specifies what will be written to the log file. It can specify either a nickname defined by a previous LogFormat directive, or it can be an explicit format string as described in the log formats section. For example, the following two sets of directives have exactly the same effect: # CustomLog with format nickname LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog logs/access_log common # CustomLog with explicit format string CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b" The third argument is optional and allows the decision on
whether or not to log a particular request to be based on the
presence or absence of a particular variable in the server
environment. If the specified environment
variable is set for the request (or is not set, in the case
of a ' Environment variables can be set on a per-request basis using the mod_setenvif and/or mod_rewrite modules. For example, if you want to record requests for all GIF images on your server in a separate logfile but not in 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 LogFormat directiveSyntax: LogFormat
format|nickname [nickname] This directive specifies the format of the access log file. The The second form of the For example: LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common
TransferLog directiveSyntax: TransferLog
file|pipe 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 (that does not define a nickname). Common Log Format is used if no other format has been specified. Example: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" TransferLog logs/access_log Apache HTTP Server Version 1.3 |