Knowledge Base

How to view Apache log files

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.

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 Flex 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.

Semi-managed dedicated servers and VPS

If you have a semi-managed Flex 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 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 access log, use the grep command. For example, to search for all HTTP GET requests in the 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

Error logs

The error log is where Apache records information 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 Flex 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.

Semi-managed dedicated servers and VPS

If you have a semi-managed Flex 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 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 error log, use the grep command. For example, to do a case-insensitive search for all occurrences of the word invalid in the 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 access and error logs in Apache, please visit http://httpd.apache.org/docs/2.2/logs.html.