Where are Apache Log Files located?


where are apache log files located

Apache is an excellent web server that provides powerful logging features. It is important to know where are Apache log files located so you can easily analyze and customize them. Let us take a look at where to find Apache log files and how to read them.

 

Where are Apache Log Files located

Apache maintains 2 log files – one for recording access and the other to log errors

Access log records every request received by your server. It also provides useful information about visitors such as IP address, browser, requested file, response code, etc.

The location of Apache log files depends on the kind of server setup, you have

 

Managed dedicated servers and VPS

If you have managed dedicated servers and VPS, then you can view Apache log files via CPanel. Log into CPanel and click on Raw Access in Metrics section or Raw Access Logs in Logs section, depending on your CPanel version

 

Unmanaged dedicated servers and VPS

In this case, you have root access and you can manage your logs anyway you want.

You will find the access log at :

For Ubuntu/Debian


/etc/httpd/logs/access_log

For CentOS/RHEL/Fedora:


/var/log/apache2/access.log

 

Similarly, you will find error logs at

For Ubuntu/Debian


/etc/httpd/logs/error_log

For CentOS/RHEL/Fedora


/var/log/apache2/error.log

 

How to Read Apache Logs

If you want to read the last 10 lines of your access log, run the command

For Ubuntu/Debian


$ sudo tail -10 /etc/httpd/logs/access_log

For CentOS/RHEL/Fedora


$ sudo tail -10 /etc/httpd/logs/access.log

 

Similarly, if you want to read the last 10 lines of your error log,

For Ubuntu/Debian


$ sudo tail -10 /etc/httpd/logs/error_log

For CentOS/RHEL/Fedora


$ sudo tail -10 /etc/httpd/logs/error.log

 

If you want to look for a particular string in your Apache logs, use the grep command

 

For example, if you want to retrieve all HTTP GET requests, look for “GET” keyword in your log

For Ubuntu/Debian


$ sudo grep GET /etc/httpd/logs/access_log

For CentOS/RHEL/Fedora


$ sudo grep GET /etc/httpd/logs/access.log

 

Similarly, if you want to get all the “invalid” requests to your server

For Ubuntu/Debian


$ sudo grep invalid /etc/httpd/logs/error_log

For CentOS/RHEL/Fedora


$ sudo grep invalid /etc/httpd/logs/error.log

 

About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!