httpd.apache.org/docs/logs.html#combined
Piped Logs * 10 Virtual Hosts * 11 Other Log Files + 12 PID File + 13 Script Log + 14 Rewrite Log Security Warning Anyone who can write to the directory where Apache is writing a log file can almost certainly gain access to the uid that the server is started as, which is normally root. Do NOT give people write access to the directory the logs are stored in without being aware of the consequences; In addition, log files may contain information supplied directly by the client, without escaping. Therefore, it is possible for malicious clients to insert control-characters in the log files, so care must be taken in dealing with raw logs. Error Log Related Directives 16 ErrorLog 17 LogLevel The server error log, whose name and location is set by the 18 ErrorLog directive, is the most important log file. This is the place where Apache httpd will send diagnostic information and record any errors that it encounters in processing requests. It is the first place to look when a problem occurs with starting the server or with the operation of the server, since it will often contain details of what went wrong and how to fix it. On unix systems it is also possible to have the server send errors to syslog or 19 pipe them to a program. The format of the error log is relatively free-form and descriptive. But there is certain information that is contained in most error log entries. The second entry lists the severity of the error being reported. The 20 LogLevel directive is used to control the types of errors that are sent to the error log by restricting the severity level. The third entry gives the IP address of the client that generated the error. Beyond that is the message itself, which in this case indicates that the server has been configured to deny the client access. The server reports the file-system path (as opposed to the web path) of the requested document. A very wide variety of different messages can appear in the error log. The error log will also contain debugging output from CGI scripts. Any information written to stderr by a CGI script will be copied directly to the error log. It is not possible to customize the error log by adding or removing information. However, error log entries dealing with particular requests have corresponding entries in the 21 access log. For example, the above example entry corresponds to an access log entry with status code 403. Since it is possible to customize the access log, you can obtain more information about error conditions using that log file. During testing, it is often useful to continuously monitor the error log for any problems. On unix systems, you can accomplish this using: tail -f error_log Access Log Related Modules 22 mod_log_config Related Directives 23 CustomLog 24 LogFormat 25 SetEnvIf The server access log records all requests processed by the server. The location and content of the access log are controlled by the 26 CustomLog directive. The 27 LogFormat directive can be used to simplify the selection of the contents of the logs. This section describes how to configure the server to record information in the access log. Of course, storing the information in the access log is only the start of log management. The next step is to analyze this information to produce useful statistics. Log analysis in general is beyond the scope of this document, and not really part of the job of the web server itself. For more information about this topic, and for applications which perform log analysis, check the 28 Open Directory or 29 Yahoo. Various versions of Apache httpd have used other modules and directives to control access logging, including mod_log_referer, mod_log_agent, and the TransferLog directive. The CustomLog directive now subsumes the functionality of all the older directives. The format is specified using a 30 format string that looks much like a C-style printf format string. For a complete list of the possible contents of the format string, see the 31 mod_log_config documentation. Common Log Format A typical configuration for the access log might look as follows. LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog logs/access_log common This defines the nickname common and associates it with a particular log format string. The format string consists of percent directives, each of which tell the server to log a particular piece of information. Literal characters may also be placed in the format string and will be copied directly into the log output. The quote character must be escaped by placing a back-slash before it to prevent it from being interpreted as the end of the format string. The format string may also contain the special control characters "\n" for new-line and "\t" for tab. The CustomLog directive sets up a new log file using the defined nickname. The filename for the access log is relative to the 32 ServerRoot unless it begins with a slash. The above configuration will write log entries in a format known as the Common Log Format (CLF). This standard format can be produced by many different web servers and read by many log analysis programs. If 33 HostnameLookups is set to On, then the server will try to determine the hostname and log it in place of the IP address. However, this configuration is not recommended since it can significantly slow the server. Instead, it is best to use a log post-processor such as 34 logresolve to determine the hostnames. The IP address reported here is not necessarily the address of the machine at which the user is sitting. If a proxy server exists between the user and the server, this address will be the address of the proxy, rather than the originating machine. In this case, the information that is not available is the RFC 1413 identity of the client determined by identd on the clients machine. This information is highly unreliable and should almost never be used except on tightly controlled internal networks. Apache httpd will not even attempt to determine this information unless 35 IdentityCheck is set to On. The same value is typically provided to CGI scripts in the REMOTE_USER environment variable. If the status code for the request (see below) is 401, then this value should not be trusted because the user is not yet authenticated. If the document is not password protected, this entry will be "-" just like the previous one. The format is: day/month/year:hour:minute:second zone day = 2*digit month = 3*letter year = 4*digit hour = 2*digit minute = 2*digit second = 2*digit zone = (+' | -') 4*digit It is possible to have the time displayed in another format by specifying %{format}t in the log format string, where format is as in strftime from the C standard library. The request line contains a great deal of useful information. It is also possible to log one or more parts of the request line independently. For example, the format string "%m %U%q %H" will log the method, path, query-string, and protocol, resulting in exactly the same output as "%r". This information is very valuable, because it reveals whether the request resulted in a successful response (codes beginning in 2), a redirection (codes beginning in 3), an error caused by the client (codes beginning in 4), or an error in the server (codes beginning in 5). The full list of possible status codes can be found in the 36 HTTP specification (RFC2616 section 10). If no content was returned to the client, this value will be "-". Combined Log Format Another commonly used format string is called the Combined Log Format. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined CustomLog log/acces_log combined This format is exactly the same as the Common Log Format, with the addition of two more fields. Each of the additional fields uses the percent-directive %{header}i, where header can be any HTTP request header. This gives the site that the client reports having been referred from. This is the identifying information that the client browser reports about itself. Multiple Access Logs Multiple access logs can be created simply by specifying multiple CustomLog directives in the configuration file. For example, the following directives will create three access logs....
|