GrepBoard/Manuals
605 manuals ·

Apache log file location and LogFormat explained

·Tested on httpd 2.4.69 (Docker) · Ubuntu 24.04 apache2 2.4.58 · Rocky Linux 9 httpd 2.4.62 · 2026-11·Test scope ↓·7 steps

Apache logs are in /var/log/apache2 on Ubuntu, /var/log/httpd on Rocky and docker logs for the httpd image. Find them via ErrorLog and CustomLog.

Where Apache writes its logs depends on how it was installed. The Ubuntu package uses /var/log/apache2/, the Rocky Linux 9 package uses /var/log/httpd/, and the official httpd Docker image writes no files: it sends logs to standard output and standard error. This guide shows where the path is set and how to read one access-log line and one error-log line.

[1] Start with the default location for your install, read from each environment's default configuration.

InstallError logAccess log
Ubuntu 24.04 apache2/var/log/apache2/error.log/var/log/apache2/access.log, plus the shared other_vhosts_access.log
Rocky Linux 9 httpd/var/log/httpd/error_log/var/log/httpd/access_log
Docker httpd:2.4standard error (stderr)standard output (stdout)

Only ErrorLog has a documented default: logs/error_log under ServerRoot on Unix. CustomLog, which sets the access log, has no default, and the paths above are values each distribution wrote into its configuration. For a source build or a package not listed, find the CustomLog in the active configuration. Check permissions too. On Ubuntu the log files are root:adm with mode rw-r-----, and on Rocky /var/log/httpd is drwx------, so a normal user's Permission denied is a permission problem, not a wrong path.

[2] Find the real path in the configuration. ErrorLog sets the error log. CustomLog sets the access log location plus a format name, LogFormat defines the format, and LogLevel sets which severities reach the error log. A virtual host with its own CustomLog sends its requests to its own file. Ubuntu 24.04:

console
# grep -RnE "^\s*(ErrorLog|LogLevel|CustomLog)" /etc/apache2/apache2.conf /etc/apache2/conf-enabled /etc/apache2/sites-enabled/etc/apache2/apache2.conf:134:ErrorLog ${APACHE_LOG_DIR}/error.log/etc/apache2/apache2.conf:143:LogLevel warn/etc/apache2/conf-enabled/other-vhosts-access-log.conf:2:CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined/etc/apache2/sites-enabled/000-default.conf:20:	ErrorLog ${APACHE_LOG_DIR}/error.log/etc/apache2/sites-enabled/000-default.conf:21:	CustomLog ${APACHE_LOG_DIR}/access.log combined# grep -n "APACHE_LOG_DIR" /etc/apache2/envvars23:export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

${APACHE_LOG_DIR} comes from envvars, so running apache2 directly fails with AH00111 ... is not defined. See Fix Apache AH00111. Rocky Linux 9: the relative path logs/ goes through the /etc/httpd/logs symbolic link to /var/log/httpd.

console
# grep -nE "^\s*(ErrorLog|LogLevel|CustomLog)" /etc/httpd/conf/httpd.conf187:ErrorLog "logs/error_log"194:LogLevel warn222:    CustomLog "logs/access_log" combined# ls -ld /etc/httpd/logslrwxrwxrwx 1 root root 19 Oct 22 21:04 /etc/httpd/logs -> ../../var/log/httpd

[3] The Docker httpd image creates no log files. Its configuration sends both logs to the standard streams (/proc/self/fd/2, /proc/self/fd/1). This is docker logs for the default configuration after two requests.

console
$ docker run --rm httpd:2.4 grep -nE '^\s*(ErrorLog|LogLevel|CustomLog)' /usr/local/apache2/conf/httpd.conf317:ErrorLog /proc/self/fd/2324:LogLevel warn346:    CustomLog /proc/self/fd/1 common$ docker logs gblab-apache-log-location-format 2>&1AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this messageAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message[Sun Nov 08 22:22:56.861433 2026] [mpm_event:notice] [pid 1:tid 1] AH00489: Apache/2.4.69 (Unix) configured -- resuming normal operations[Sun Nov 08 22:22:56.862064 2026] [core:notice] [pid 1:tid 1] AH00094: Command line: 'httpd -D FOREGROUND'203.0.113.5 - - [08/Nov/2026:22:22:58 +0000] "GET / HTTP/1.1" 200 191203.0.113.5 - - [08/Nov/2026:22:22:58 +0000] "GET /missing.html HTTP/1.1" 404 236

Error-log and access-log lines arrive as one stream. The logs folder inside the container is empty, so use docker logs rather than cat on a file. For AH00558, see Fix Apache AH00558.

[4] Read an access-log line in the order of the LogFormat placeholders. This log was written to a file in the combined format (see [6] for how), with a Referer header on the first request.

console
$ cat logs5/access_log203.0.113.5 - - [08/Nov/2026:22:23:02 +0000] "GET / HTTP/1.1" 200 191 "https://example.com/start" "curl/8.5.0"203.0.113.5 - - [08/Nov/2026:22:23:02 +0000] "GET /missing.html HTTP/1.1" 404 236 "-" "curl/8.5.0"

From the left: %h client address (the proxy if one is in front), %l identd identity and %u authenticated user (both - when absent), %t time received, \"%r\" request line (method, path, protocol), %>s final status code, %b body bytes (headers excluded, - when none), then the Referer and User-Agent headers.

%>s is the final status after internal redirects, while %s is the status of the original request. The Ubuntu combined format uses %O instead of %b.

console
# grep -n " combined$" /etc/apache2/apache2.conf213:LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

%b is the response body size, while %O is the bytes actually sent including headers (it needs mod_logio), so they count different things. For a completed response %O is larger by the header size, and the documentation says %O can be zero if the request is aborted before a response is sent. To add the request duration (%D, microseconds) and count slow requests, see Apache reached MaxRequestWorkers.

[5] An error-log line has the default ErrorLogFormat layout. Here the same container runs with LogLevel info and a request for a missing file.

console
$ cat logs5/error_log[Sun Nov 08 22:23:00.180559 2026] [mpm_event:notice] [pid 1:tid 1] AH00489: Apache/2.4.69 (Unix) configured -- resuming normal operations[Sun Nov 08 22:23:00.180764 2026] [mpm_event:info] [pid 1:tid 1] AH00490: Server built: Nov  5 2026 07:15:08[Sun Nov 08 22:23:00.180781 2026] [core:notice] [pid 1:tid 1] AH00094: Command line: 'httpd -D FOREGROUND'[Sun Nov 08 22:23:02.210989 2026] [core:info] [pid 9:tid 22] [client 203.0.113.5:45184] AH00128: File does not exist: /usr/local/apache2/htdocs/missing.html

From the left: timestamp (to microseconds), [module:severity], [pid:tid], [client address:port] when the message belongs to a request, then the AH code and the message. Search for the AH code as it is. The last line has severity info. According to the official documentation, the 404 message File does not exist moved to info in 2.4, so the default LogLevel warn keeps it out of the error log. Find 404s by the 404 in the access log, or use LogLevel warn core:info, as the documentation says, to log them again.

[6] How to send the logs to files, and what to watch for. The container behind [4] and [5] was started after changing the ErrorLog and CustomLog lines in httpd.conf to these:

httpd.conf
ErrorLog "logs/error_log"CustomLog "logs/access_log" combined

On a package install, check the syntax, then reload (apache2ctl on Ubuntu, apachectl on Rocky). graceful does not cut off requests in progress.

console
# apache2ctl configtest# apache2ctl graceful

File logs keep growing. See Create and test a logrotate config; the official documentation also presents CustomLog "|…/rotatelogs …" combined as the recommended approach. Keep the log directory writable only by the user that starts the server. That is the security warning the documentation attaches to ErrorLog.

[7] Pick the guide that matches the text you found in the log.

Log text or symptomGuide
AH00072 make_sock: could not bindPort in use, missing IP or permission
AH00558 ServerName warningSet a global ServerName
AH00111 ${APACHE_RUN_DIR} is not definedStart through the script that reads envvars
403 with AH01630Require all granted
403 with AH01797 client deniedRemove leftover 2.2-style rules
AH00124 ... 10 internal redirectsBreak the rewrite loop
Invalid command 'RewriteEngine'Enable mod_rewrite
Primary script unknownMatch the php-fpm path
AH00013 threaded MPMprefork, or event with PHP-FPM
Proxy 503 with AH01114Fix backend address and port
Certificate and key AH02565Compare public key hashes
Slow, AH00484 or AH00161Apache reached MaxRequestWorkers

For package version numbers and which security fixes are included, see Apache 2.4.69 and Ubuntu 24.04 status.

Analyze your Apache log in the browser ↗ — nothing is uploaded.

#apache#httpd#access-log#error-log#logformat