To view Apache 2 logs on Ubuntu, you can look in the /var/log/apache2 directoriy. Here are the common log files you’ll want to check:
Access Logs
These logs contain information about requests that come to the Apache server. This log can contain client IP, requested URL, response status, and more.
Path: /var/log/apache2/access.log
View: sudo tail -f /var/log/apache2/access.log
Error Logs
This log file records any errors Apache encounters, including server misconfigurations, failed requests, or issues with the application running on the server.
Path: /var/log/apache2/error.log
View: sudo tail -f /var/log/apache2/error.log
Other Logs (Virtual Hosts)
If you’re using virtual hosts (for different websites hosted on the same server), you might have separate logs for each virtual host. These logs would be inside a subdirectory under “/var/log/apache2/”, such as “/var/log/apache2/your-site-name-access.log” and “/var/log/apache2/your-site-name-error.log“.
To actively monitor Apache logs, you can use “tail -f” to follow the logs in real-time. If you’re debugging something, this is very helpful.
Conclusion
Apache only has a few log files. For virtual host you will find logs for each virtual host. These normally come in the format of /var/log/apache2/your-site-name-access.log and /var/log/apache2/your-site-name-error.log.