Where the Logs Are
| Log | Debian and Ubuntu | AlmaLinux and Rocky Linux |
|---|---|---|
| Access | /var/ | /var/ |
| Error | /var/ | /var/ |
On Debian and Ubuntu, virtual hosts without a log of their own write to other_ in the same folder. On AlmaLinux and Rocky Linux, the default HTTPS site from mod_ssl_, ssl_, and ssl_ files. Reading the logs needs sudo. An overview of the other system logs is in Linux log files.
Follow a Log Live
sudo tail -f /var/log/apache2/error.logLoad the failing page in a browser while this runs, and the matching lines appear as they are written. Press Ctrl+C to stop. More options in tail -f.
Reading an Access Log Line
Both families log in the combined format by default:
203.0.113.10 - - [28/Nov/2026:14:02:11 +0000] "GET /blog/ HTTP/1.1" 200 5320 "https://example.com/" "Mozilla/5.0 (X11; Linux x86_64)"It is defined by a LogFormat line like this one:
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined- %h: the client's IP address.
- %l and %u: the identd name and the logged-in user; usually a dash.
- %t: date and time of the request.
- %r: the request line: method, path, and protocol.
- %>s: the final status code, such as 200, 404, or 500.
- %O: bytes sent, headers included. AlmaLinux and Rocky Linux use
%b, the size of the response body. - Referer and User-Agent: the page that linked here and the client software.
Reading the Error Log
Each error line starts with the time, then the module and level in brackets (for example [php:error] or [core:error]), the process ID, and the client address, followed by the message. Startup problems such as a syntax error or a port in use also go to the journal; see journalctl.
A Log Pair per Site
In each virtual host:
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combinedOn AlmaLinux and Rocky Linux, write the full path, such as /var/log/httpd/example.com-error_. Test with sudo apachectl configtest and reload; a reload reopens the log files without dropping requests.
Set the Detail with LogLevel
The default level is warn. The levels, from least to most detail, are emerg, alert, crit, error, warn, notice, info, debug, and trace1 to trace8. You can raise one module only:
LogLevel warn ssl:infoUse debug and trace levels only while you investigate, then set the line back and reload.
Useful Filters
# Requests that ended in a 5xx error
sudo awk '$9 ~ /^5/' /var/log/apache2/access.log | tail -20
# Addresses with the most requests
sudo awk '{print $1}' /var/log/apache2/access.log | sort | uniq -c | sort -rn | head
# Most requested paths
sudo awk '{print $7}' /var/log/apache2/access.log | sort | uniq -c | sort -rn | headIn the combined format, field 9 is the status and field 7 is the path. See awk for logs. Older, compressed logs can be searched with zgrep.
Rotation and Retention
logrotate renames the logs on a schedule, keeps a set number of old copies, and reloads Apache so it opens new files. The rules are in /etc/logrotate.d/apache2 (daily, 14 copies, compressed) or /etc/logrotate.d/httpd (compression only if /etc/logrotate.conf turns it on); per-site logs in the same folder are covered by the same rules. A debug run shows what would happen without changing any file:
sudo logrotate -d /etc/logrotate.d/apache2Access logs hold IP addresses and visited addresses, which can identify people. Keep them only as long as you need them for security and troubleshooting, and set that period with the rotate count rather than by deleting files by hand.
Behind a Proxy or CDN
If every line shows the same address, a proxy sits in front of Apache. mod_RemoteIPHeader line restores the visitor's address, and %a in place of %h logs it; see Apache vs Nginx for that setup.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations