Apache Guide: Logging, Part 2 -- Error Logs
Last week, O gentle reader, we talked about the Apache access log, and what the information in there means. This week, we're going to talk about the other standard log file: the error log.Not all log files are the same. In this article, Rich Bowen looks at error log files, which can provide valuable information when your Apache Web server misbehaves.
As you'll see in coming weeks, these two logs are generated by different processes. And you'll see in this article that the format of the entries in the error log are rather different from the entries in the access log that we saw last week.
But the two logs are similar, in that they both provide a lot of useful information which you can use in analyzing how your server is being used, and what is going wrong.
Your error log file should be in the same location as your access
log file. It will be called
error_log, or, on Windows machines,
The location of your error log can be configured with the
The location, unless it has a leading slash, is assumed to be relative
In a default Apache installation, the log file is located in
/usr/local/apache/logs As before, if you installed with one of the various
package managers out there, you may find it just about anywhere.
The error log, as the name suggests, contains a record of everything that went wrong while your server was running. It also contains general diagnostic messages, such as a notification of when your server was restarted, or shut down.
You can set your log level higher or lower to control the amount, and type, of
messages that appear in your log file. This is configured with the
directive. The default setting of this directive is
error, which tells
you about error conditions. For a full listing of the different things
you can set it to, see the Apache documentation at
In most cases, the things that you see in your log file will be in two categories: document errors and CGI errors. You will also occasionally see configuration errors, and, as I mentioned above, server start and server stop messages.
Document errors are things that are in the 400 series of server response codes. The most common of these is 404 - Document Not Found. 404's are followed by, at least on my server, authentication errors.
A 404 error occurs whenever someone requests a resource--a URL - that is not on your server. Either they have mistyped something, or there was a typo'ed link somewhere, or you moved or deleted a document that used to be on your server.
Incidentally, Jakob Nielson says that you should never move or delete any resource from your website without providing a redirect or some variety. If you're not already familiar with Nielson's writings, you should take a look sometime. http://www.zdnet.com/devhead/alertbox/
When a client is unable to locate a document on your server, you'll see an entry like this in your logs:
[Fri Aug 18 22:36:26 2000] [error] [client 192.168.1.6] File does not exist: /usr/local/apache/bugletdocs/Img/south-korea.gif
Note that, as in the case of the
access_logfile, this record is broken down into several fields.