Ubuntu Unleashed 2011 Edition: Covering 10.10 and 11.04 (6th Edition)
| Apache provides logging for just about any web access information you might be interested in. Logging can help with
Two standard log files are generated when you run your Apache server: access_log and error_log. They are found under the /var/log/httpd directory. (Others include the SSL logs ssl_access_log, ssl_error_log and ssl_request_log.) All 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. These directives appear in your httpd.conf file. A new log format can be defined with the LogFormat directive: 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 you're using the common log format or the combined log formatboth of which are defined in the default configuration files. The following variables are available for LogFormat statements:
You can put a conditional in front of each variable to determine whether the variable is displayed. If the variable isn't displayed, - is displayed instead. These conditionals are in the form of a list of numerical return values. For example, %!401u displays the value of REMOTE_USER unless the return code is 401. You can then specify the location and format of a log file using the CustomLog directive: CustomLog logs/access_log common
If it is not specified as an absolute path, the location of the log file is assumed to be relative to the ServerRoot. |