How To Use Apache Access Log & Apache Error Log

This article describes how to view Apache log files on a dedicated server or VPS. If you're experiencing web server difficulties, or you just want to see what Apache is doing, log files should be your first stop. Apache records information about all visitors to your site, as well as any problems the server encounters. To do this, Apache uses two types of log files: access logs and error logs.

Shared hosting accounts cannot view the raw Apache log files for the entire server. However, you can still view log file information for your own account. For information about how to view the access log for your account, please see this article. For information about how to view the error log for your account, please see this article.

Apache Access logs

Apache uses the access log files to record information about every visitor to your site. You can see which files visitors view, how the web server responds to requests, and other information such as the web browsers visitors use.

Managed dedicated servers and VPS

If you have a managed Dedicated Server or VPS, you can view the raw Apache access logs in cPanel. For more information about how to do this, please see this article.

Unmanaged dedicated servers and VPS

If you have an unmanaged Dedicated Server or VPS, you have root access. This means you can manipulate and process the Apache access log files any way you want.

For example, you can log in to your server using SSH and type the following command to view the last 100 lines in the Apache access log:

sudo tail -100 /etc/httpd/logs/access_log

If your server is running Debian or Ubuntu, type the following command instead:

sudo tail -100 /var/log/apache2/access.log

To search for a particular term in the Apache access log, use the grep command. For example, to search for all HTTP GET requests in the Apache access log, type the following command:

sudo grep GET /etc/httpd/logs/access_log

If your server is running Debian or Ubuntu, type the following command instead:

sudo grep GET /var/log/apache2/access.log

Apache Error logs

The Apache error log is where information is recorded about any errors or anomalies it encounters. Many of the “errors” Apache records are typically minor, such as a visitor requesting a file that doesn't exist. Apache also uses the error logs to record warnings that can indicate a potential problem with a particular event or configuration.

Managed dedicated servers and VPS

If you have a managed Dedicated Server or VPS, you can view the Apache error logs in cPanel. For more information about how to do this, please see this article.

Unmanaged dedicated servers and VPS

If you have an unmanaged Dedicated Server or VPS, you have root access. This means you can manipulate and process the Apache error log files any way you want.

For example, you can log in to your server using SSH and type the following command to view the last 100 lines in the Apache error log:

sudo tail -100 /etc/httpd/logs/error_log

If your server is running Debian or Ubuntu, type the following command instead:

sudo tail -100 /var/log/apache2/error.log

To search for a particular term in the Apche error log, use the grep command. For example, to do a case-insensitive search for all occurrences of the word invalid in the Apache error log, type the following command:

sudo grep -i invalid /etc/httpd/logs/error_log

If your server is running Debian or Ubuntu, type the following command instead:

sudo grep -i invalid /var/log/apache2/error.log

More Information

For more information about the Apache access log and the Apache error log, please visit http://httpd.apache.org/docs/2.2/logs.html.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.