Using Apache Logs

Proper monitoring of log files is an important part of Web server maintenance.

Apache provides several logs that can be configured and various ways of organizing them. However, Web site log maintenance should be regarded as a black art: There is no single way to do it right. Be aware that decisions you make regarding logs can have unintended consequences. To take one example, Web server logs that are not maintained can swell to fill available disk space.

A useful technique for monitoring log files is to use the tail command with its –f switch to follow the end of the log file as the file grows in a terminal or teelnet window. For more information on tail, see Chapter 11.

By default, Red Hat Linux 6 is initialized with only an error log.

To view the Apache error log:

1.
Open a terminal or telnet window.

2.
At the command line, type the following:

tail –f /etc/httpd/logs/error_log

3.
Press Enter.

The error log files will be displayed in the terminal window ( Figure 14.17 ), with new lines displayed in the window as they are written to the log.

Figure 14.17. By "tailing" the error log file, you can track errors as they are writtento the log.


Tip

To end the error log display and return to the command prompt, press Ctrl+C.


Tip

If all is well, there will not be much to see in an error log file.


To enable and view the access log:

1.
Open the httpd.conf file in a text editor.

2.
Uncomment the access log directive by removing the hash symbol from the beginning of the line. It should now read:

CustomLog logs/access_log _ combined

3.
Save the revised httpd.conf file.

4.
Open a terminal or telnet window.

5.
At the command line, type the following:

tail –f /etc/httpd/logs/ _ access_log

6.
Press Enter.

The access log files will be displayed in the terminal window ( Figure 14.18 ), with new lines displayed in the window as they are written to the log.

Figure 14.18. You can use the access logs to analyze visitors to your sites and the resources they request.


Tip

Unlike error logs, access logs grow quickly if you have a high-traffic site.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.144.248