apache tutorial - How to view Apache log files - apache - apache web server - apache server - apache2



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

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.

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
click below button to copy the code. By Apache tutorial team
  • If your server is running Debian or Ubuntu, type the following command instead:
sudo tail -100 /var/log/apache2/access.log
click below button to copy the code. By Apache tutorial team
  • 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
click below button to copy the code. By Apache tutorial team
  • If your server is running Debian or Ubuntu, type the following command instead:
sudo grep GET /var/log/apache2/access.log
click below button to copy the code. By Apache tutorial team

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.

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
click below button to copy the code. By Apache tutorial team
  • If your server is running Debian or Ubuntu, type the following command instead:
sudo tail -100 /var/log/apache2/error.log
click below button to copy the code. By Apache tutorial team
  • 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
click below button to copy the code. By Apache tutorial team
  • If your server is running Debian or Ubuntu, type the following command instead:
sudo grep -i invalid /var/log/apache2/error.log
click below button to copy the code. By Apache tutorial team

Related Searches to How to view Apache log files