# Viewing the Apache access log and error log

> Find and read the Apache access log and error log to troubleshoot errors and monitor visits to your website.

Source: https://helpcenter.ruachost.com/developers/web-servers/viewing-the-apache-access-log-and-error-log/

Apache maintains two primary log files: the **access log** and the **error log**. On **ruachost.com**, these logs help administrators monitor traffic, troubleshoot issues, and maintain server security.

## Why Check Apache Logs?

- Diagnose website errors and performance issues.
- Monitor visitor activity and requests.
- Detect suspicious or unauthorized access attempts.
- Verify server responses and application behavior.

## Access Log

The **access log** records every request made to your server. It includes:

- Visitor IP address.
- Requested URL.
- HTTP response code (e.g., 200, 404, 500).
- Browser and operating system details.

### Viewing Access Logs

- **Managed Dedicated/VPS Accounts (cPanel):** Access raw Apache access logs directly in **cPanel → Metrics → Raw Access Logs**.
- ### Unmanaged Dedicated/VPS Accounts (SSH)

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

  On Debian/Ubuntu systems:

  ```bash
  sudo tail -100 /var/log/apache2/access.log
  ```
- To search for specific requests (e.g., GET requests):

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

## Error Log

The **error log** records warnings, errors, and anomalies encountered by Apache. Examples include:

- Missing files (404 errors).
- Permission issues.
- Misconfigured directives.
- Application errors.

### Viewing Error Logs

- **Managed Dedicated/VPS Accounts (cPanel):** Access raw Apache error logs in **cPanel → Metrics → Errors**.
- ### Unmanaged Dedicated/VPS Accounts (SSH)

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

  On Debian/Ubuntu systems:

  ```bash
  sudo tail -100 /var/log/apache2/error.log
  ```
- To search for specific errors (e.g., invalid requests):

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

  ```
  ```

> **Important Notes:**
- Shared hosting accounts cannot view raw server‑wide logs, but can access account‑specific logs via cPanel.
- Always back up logs before deleting or rotating them.
- Use `tail -f` to monitor logs in real time.
- Logs are critical for security audits and compliance monitoring.
