Creating a Custom Log File
CustomLog logs/access_log common TransferLog logs/sample.log You may want to create new log files in addition to the ones included with Apache. This example uses CustomLog to create a new log file and store the information defined by a previously defined log format named common , as seen in the previous section. You can replace the nickname with the format definition itself. An additional, simpler directive is TRansferlog , which will just take the definition provided by the latest LogFormat directive. |
Redirecting Logs to an External Program
TransferLog "bin/rotatelogs /var/logs/apachelog 86400"
You can also use
CustomLog
or
transferLog
to redirect ("pipe") the log output to an external program instead of a file. To do this, you need to begin with the pipe character "", followed by the
When an external program is used, it will be run as the
|
Logging
|
Monitoring Who Is Linking to Your Website
SetEnvIfNoCase Referer www\.example\.com internalre- ferral LogFormat "%{Referer}i -> %U" referer CustomLog logs/referer.log referer env=!internalre- ferral
In order to monitor who is linking to your website, you can log the
Referer:
header from the request. This header contains the URL that linked to the page being
|
Monitoring Apache with mod_status
<Location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from 192.168.0 </Location>
The
mod_status
module provides information on server activity and performance, allowing a server administrator to find out how well their server is performing. An HTML page is presented that gives the current server statistics in an easily readable form, such as the number of workers serving
If you include an
ExtendedStatus On
directive, additional information will be displayed, such as individual information about each worker status, total number of
Bear in mind that, depending on your server load, this extended statistics recording may have a significant impact on server performance. This example shows how to enable the mod_status monitoring, while restricting access to this information to only certain IP addresses. You can now access server statistics by using a Web browser to access the page at http://www.example.com/server-status. |