Standard Apache Error Logging


Apache can be configured to log error messages and debugging information, in addition to client requests. In addition to errors generated by Apache itself, CGI errors can be logged.

Each error log entry is prefixed by the time the error occurred and the client IP address or hostname, if available. As with HTTP request logging, you can log error information to a file or program. On Unix systems, you can also log to the syslog daemon. On Windows, errors can be logged in the Windows event log and would then be viewable via the Windows Event Viewer. Use the ErrorLog directive to define where you want your logs to go.

Logging Errors to a File

A file argument indicates the path to the error log file. If the path is relative, it is assumed to be relative to the server root. By default, the error log file will be located in the logs directory and will be named error_log on Unix and error.log on Windows. The following is an example:

 ErrorLog logs/my_error_log 

Logging Errors to a Program

You can specify the path to a program, prefixed by a pipe |. Apache will log errors to the standard input of the program, and the program will further process them. The following is an example:

 ErrorLog "|/usr/local/bin/someprogram" 

The syslog Daemon Argument

On a Unix system, if you specify syslog as an argument, you can log error messages to the Unix system log daemon syslogd. By default, log errors are logged to the syslog facility local7. The facility is the part of the system generating the error. You can specify a facility by providing syslog: facility as an argument. Examples of syslog facilities are mail, uucp, local0, local1, and so on. For a complete list, look at the documentation for syslog included with your system (try man syslogd or man syslogd.conf at the command line). The following is an example of logging to syslog:

 ErrorLog syslog:local6 

The LogLevel Directive

The error information provided by Apache has several degrees of importance. You can choose to log only important messages and disregard informational or trivial warning messages. The LogLevel directive takes an error-level argument. Only errors of that level of importance or higher will be logged.

Table 25.2 specifies the valid values for the LogLevel directive, as specified by the Apache documentation. By default, the LogLevel value is warn. That should be enough for most Apache installations. If you are trying to troubleshoot a specific configuration, you can alter the level to debug.

Table 25.2. LogLevel Options as Described in the Apache Documentation

Setting

Description

Example

emerg

Emergenciessystem is unusable

Child cannot open lock file. Exiting.

alert

Action must be taken immediately

getpwuid: couldn't determine user name from uid.

crit

Critical conditions

socket: Failed to get a socket, exiting child.

error

Error conditions

Premature end of script headers.

warn

Warning conditions

Child process 1234 did not exit, sending another SIGHUP.

notice

Normal but significant conditions

httpd: caught SIGBUS, attempting to dump core in...

info

Informational

Server seems busy, (You may need to increase StartServers, or Min/MaxSpareServers)...

debug

Debug-level messages

Opening config file...




Sams Teach Yourself PHP MySQL and Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (4th Edition)
ISBN: 067232976X
EAN: 2147483647
Year: 2003
Pages: 333
Authors: Julie Meloni

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net