Apache produces these log files: error log, access log. The default configuration puts the error log in "$APACHE_home\logs\error.log" and access log in "$APACHE_home\logs\access.log". Take a quick glance into these log files.
Error Log: The configuration directives related to error logging are ErrorLog and LogLevel:
- ErrorLog directive specifies the location of the error log file. For example:
# ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a <VirtualHost> # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here. ErrorLog logs/error.log
- LogLevel directive controls the types of error messages written to the error log. For example:
# LogLevel: Control the number of messages logged to the error_log. # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn
Sample entries in the error log are as follows:
[Sun Oct 18 16:53:40 xxxx] [error] [client 127.0.0.1] Invalid method in request get /index.html HTTP/1.0
[Sun Oct 18 18:36:20 xxxx] [error] [client 127.0.0.1] File does not exist: d:/myPorject/apache2/htdocs/t.html
[Sun Oct 18 19:58:41 xxxx] [error] [client 127.0.0.1] client denied by server configuration: d:/myPorject/apache2/htdocs/forbidden/index.html
Access Log: The configuration directives related to access logging are CustomLog and LogFormat:
- The CustomLog directive specifies the locations of the access log files. There are 3 types of access logs: common, referrer and agent. Common access log captures client access. Referrer access log captures the "referrer" (as in the Referer request header) of the request. (Referrer can be used for access control or accounting purpose such as e-advertising.) Agent access log captures the types of the browsers used in issuing the request (as in the User-Agent request header). Most installations do not need the referrer and agent access logs. For example:
# The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost> # container, they will be logged here. Contrariwise, if you *do* # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. CustomLog "logs/access.log" common #CustomLog logs/referer.log referer #CustomLog logs/agent.log agent
You can combine all the 3 access logs into a single log file, using keyword "combined".# If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. #CustomLog "logs/access.log" combined
- LogFormat directive controls the format of the access logs. For example:
# The following directives define some format nicknames for use with # a CustomLog directive. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent
Some sample entries in the "common" access log are as shown:
127.0.0.1 - - [18/Oct/2009:15:41:30 +0800] "GET / HTTP/1.1" 200 44
127.0.0.1 - - [18/Oct/2009:18:36:20 +0800] "GET /t.html HTTP/1.0" 404 204
127.0.0.1 - - [18/Oct/2009:18:32:05 +0800] "get /index.html HTTP/1.0" 501 215
Apache mod_dumpio Module
This module allows for the logging of all input received by Apache and/or all output sent by Apache to be logged / dumped to the error.log file.Reference Link
No comments:
Post a Comment
comment here