Where are Apache Access and Error Logs Stored?
Locating the default access and error logs for the Apache HTTP Server is a crucial first step for troubleshooting website errors, tracking visitor traffic, and monitoring server security. Depending on your operating system—whether it is a Linux distribution like Ubuntu, Debian, CentOS, or RHEL, or a Windows environment—Apache stores these critical log files in different default directories. This guide provides a quick reference to help you find these logs instantly across various platforms, along with the commands needed to view them.
Default Log Locations by Operating System
Because Apache is packaged differently across Linux distributions and
operating systems, the file paths to the access.log and
error.log will vary.
| Operating System / Distribution | Log Directory Path |
|---|---|
| Ubuntu / Debian (Apache2) | /var/log/apache2/ |
| CentOS / RHEL / Fedora (httpd) | /var/log/httpd/ |
| macOS (Built-in Apache) | /var/log/apache2/ |
| Windows (Default XAMPP Installation) | C:\xampp\apache\logs\ |
In most Linux setups, the files are specifically named
access.log for visitor traffic and error.log
for system diagnostics and PHP errors. On Red Hat-based systems
(CentOS/RHEL), they are often named access_log and
error_log.
How to Find Custom Log Paths
If your server hosts multiple websites using Virtual Hosts, the logs might be saved in custom directories instead of the default paths listed above. You can find the exact location by checking the Apache configuration files.
- On Ubuntu/Debian: Look inside the virtual host
configuration files located in
/etc/apache2/sites-enabled/. - On CentOS/RHEL: Look inside
/etc/httpd/conf/httpd.confor the individual configuration files in/etc/httpd/conf.d/.
Open the relevant configuration file and look for the following two directives:
ErrorLog /path/to/custom/error.log CustomLog /path/to/custom/access.log combined
Useful Commands to View Apache Logs
If you are using a Linux server via SSH, you can use standard terminal commands to view and monitor your logs in real-time.
- View the most recent errors: To see the last 50
lines of the error log on Ubuntu, use:
sudo tail -n 50 /var/log/apache2/error.log - Watch logs in real-time: To watch live traffic or
errors as they happen, use the
-f(follow) flag:sudo tail -f /var/log/apache2/access.log - Search for specific errors: If you are looking for
a specific error code like a 404 or 500, you can filter the log using
grep:sudo grep "HTTP/1.1\" 500" /var/log/apache2/access.log