What is the ErrorLog directive in Apache?

The ErrorLog directive in Apache HTTP Server is a core configuration command that determines where the server sends its diagnostic messages and error records. This article explains its primary purpose, how to configure it, and why it is an essential tool for web server administrators diagnosing website issues or monitoring server health.

The Core Purpose of ErrorLog

When Apache encounters an issue—whether it is a broken link, a missing file, a configuration misstep, or a severe server crash—it needs a place to record that event. The ErrorLog directive specifies the file path or system log location where Apache will write these messages. Without this directive, troubleshooting server errors would be nearly impossible, as administrators would have no visibility into internal server failures.

Syntax and Configuration

The directive is typically placed within the main server configuration file (such as httpd.conf or apache2.conf) or inside specific <VirtualHost> blocks to separate logs for different websites.

The basic syntax requires the directive followed by the destination path:

ErrorLog "/var/log/apache2/error_log"

In this setup, all errors are sent to a standard file on the disk. However, Apache also allows logs to be piped to an external logging program or sent directly to the system logger (syslog) using the following formats:

How ErrorLog Works with LogLevel

The ErrorLog directive does not work alone; it is closely tied to the LogLevel directive. While ErrorLog defines where the logs go, LogLevel defines how much detail is recorded.

Administrators can adjust the verbosity from emerg (most critical, server unusable) down to debug (verbose, used for troubleshooting specific bugs). By default, Apache usually filters out low-priority messages to prevent the log file from growing too large too quickly, ensuring that only meaningful warnings and errors clutter the file.

Why it Matters for Administrators

Monitoring the error log is a fundamental practice in web server management for several key reasons: