- Table of Contents
- Copyright
- About the Lead Authors
- About the Contributing Authors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- I. Red Hat Linux Installation and User Services
- Chapter 1. Introduction to Red Hat Linux
- Chapter 2. Installation of Your Red Hat System
- Chapter 3. LILO and Other Boot Managers
- Chapter 4. Configuring the X Window System, Version 11
- Chapter 5. Window Managers
- Chapter 6. Connecting to the Internet
- Chapter 7. IRC, ICQ, and Chat Clients
- Chapter 8. Using Multimedia and Graphics Clients
- II. Configuring Services
- Chapter 9. System Startup and Shutdown
- Chapter 10. SMTP and Protocols
- Chapter 11. FTP
- Chapter 12. Apache Server
- Chapter 13. Internet News
- Chapter 14. Domain Name Service and Dynamic Host Configuration Protocol
- Chapter 15. NIS: Network Information Service
- Chapter 16. NFS: Network Filesystem
- Chapter 17. Samba
- III. System Administration and Management
- Chapter 18. Linux Filesystems, Disks, and Other Devices
- Chapter 19. Printing with Linux
- Chapter 20. TCP/IP Network Management
- Chapter 21. Linux System Administration
- Chapter 22. Backup and Restore
- Chapter 23. System Security
- IV. Red Hat Development and Productivity
- Chapter 24. Linux C/C++ Programming Tools
- Chapter 25. Shell Scripting
- Chapter 26. Automating Tasks
- Chapter 27. Configuring and Building Kernels
- Chapter 28. Emulators, Tools, and Window Clients
- V. Appendixes
- A. The Linux Documentation Project
- B. Top Linux Commands and Utilities
- C. The GNU General Public License
- D. Red Hat Linux RPM Package Listings
Logging
Apache provides for logging just about any information you might be interested in from Web accesses. There are two standard log files that are generated when you run your Apache server—access_log and error_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 log analysis tools available will assume that you are 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 CLF format. For a request without any data content, a "-" will be shown instead of 0. |
| %B | Bytes sent, excluding HTTP headers. |
| %{VARIABLE}e | The contents of the environment variable VARIABLE. |
| %f | Filename. |
| %h | Remote host. |
| %H | Request protocol. |
| %{HEADER}i | The contents of HEADER; header line(s) in the request sent to the server. |
| %l | Remote logname (from identd, if supplied). |
| %m | Request method. |
| %{NOTE}n | The contents of note NOTE from another module. |
| %{HEADER}o | The contents of HEADER; 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 contents of the query string, prepended with a ? character. If there is no query string this will evaluate to an empty string. |
| %r | First line of request. |
| %s | Status. For requests that were internally redirected, this is the status of the original request—%>s for the last. |
| %t | Time, in common log format time format. |
| %{format}t | The time, in the form given by format, which should be in strftime(3) format. See the section Basic SSI Directives for a complete list of available formatting options. |
| %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 server name according to the UseCanonicalName directive. |
| %v | The canonical ServerName of the server serving the request. |
In each variable, you can put a conditional in front of the variable that will determine whether the variable is displayed. If it is not displayed, - will be displayed instead. These conditionals are in the form of a list of numerical return values. For example, %!401u will display 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.
Dynamic Content | Next Section

Account Sign In
View your cart