Blog · WebJi® India

Apache Log Files Explained: How to Read Access and Error Logs

Quick answer: Apache writes two main logs per site: access_log (every request — IP, time, path, status, bytes, referrer, user agent) and error_log (failures, PHP errors, startup messages). On cPanel they live in ~/logs or the domain's ftp/logs; on VPS, /var/log/apache2 or /var/log/httpd.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Small Indian startup team gathered around a laptop discussing their email inbox — apache log files explained

The Two Logs: access_log vs error_log

The access log (access_log) records every request Apache processes — who asked, when, for which path, and the status sent back. A typical line reads: 203.0.113.9 - - [30/Oct/2026:10:14:02 +0530] "GET /pricing HTTP/1.1" 200 18421. The error log (error_log) records everything that went wrong — Apache faults, startup problems and PHP fatal errors — in the shape [date] [module:level] [pid] [client] message. Access logs answer "what happened"; error logs answer "why".

Three places, by setup:

  1. cPanel hosting — ~/logs/ for the account's domains, or the per-domain logs directory in File Manager
  2. VPS, Debian/Ubuntu — /var/log/apache2/access.log and error.log
  3. VPS, RHEL family — /var/log/httpd/access_log and error_log

Virtual hosts can log to custom paths (check the CustomLog directive), and LiteSpeed hosting mirrors the same layout. From there, tail -f and grep turn raw lines into answers — the combined log format section below decodes each field. For PHP-level errors that never reach Apache, our PHP error logs guide picks up where error_log ends, and Linux hosting ships both log views in cPanel.

Reading the Combined Log Format Field by Field

The combined format is the standard seven Common Log Format fields plus two headers. Read a line left to right: %h is the client IP (behind a proxy it is the proxy address), %l is the RFC 1413 identity and is almost always a hyphen meaning "not available", %u is the authenticated user (hyphen on public pages), %t is the timestamp, and "%r" is the request line — method, path and protocol. %>s is the final status after any internal redirect (plain %s is the original), and %b is the bytes sent excluding headers. Combined adds %{Referer}i (the page the visitor came from) and %{User-agent}i (the browser or bot that made the request).

A worked example: 203.0.113.9 - - [30/Oct/2026:10:14:02 +0530] "GET /pricing HTTP/1.1" 200 18421 "https://google.com/" "Mozilla/5.0 (Windows NT 10.0)" — a visitor from Google on Windows fetched /pricing successfully and received 18,421 bytes.

Status Codes You’ll Actually See

Status codes sort into four families: 2xx success, 3xx redirection, 4xx the client’s fault, 5xx the server’s fault. One Apache 2.4 detail worth knowing: with the default LogLevel of warn, routine 404s are logged at info level and never reach error_log — the access log is where you count them.

CodeFamilyWhat it means
2002xx successRequest served normally
301 / 3023xx redirectPermanent / temporary redirect served
4034xx clientForbidden — permissions or a deny rule
4044xx clientPath not found — dead link or mistyped URL
5005xx serverScript or configuration error — check error_log
5035xx serverServer temporarily unable to serve — overload or maintenance

Finding Problems: 404s, 500s, Bots

Start live: tail -f error_log while you reproduce the fault shows the failing entry as it happens. For 404s, grep the access log for the status and read the requested paths — grep ' 404 ' access_log — repeated paths point at dead links worth fixing. For 500s, take the timestamp and client IP from the access line, find the matching error_log entry, and read it: a PHP fatal error names the file and the line. For bots, group the user-agent field or grep for known crawler names, then count requests per IP to see which robots are eating your capacity.

Log Rotation and Retention

An access log grows by roughly 1 MB per 10,000 requests, so rotation is not optional. Apache’s bundled rotatelogs, wired through a piped CustomLog, rotates by time (86400 seconds) or by size (for example 100M) without a restart. Distro logrotate rotates on its own schedule, but Apache must be told to reopen its files afterwards with a graceful restart — apachectl graceful. On shared cPanel hosting the host manages rotation for you; the self-managed VPS is where you set it up yourself.

Analysis Tools: cPanel Metrics, grep, GoAccess

On WebJi® Linux hosting, cPanel’s Metrics section — Visitors, Raw Access Data and AWStats — turns the same access log into per-domain tables without SSH. On a VPS, grep and awk one-liners answer single questions fast, and GoAccess renders the access log into a live terminal dashboard of hits, status codes and top bots as the lines arrive. Match the tool to your access level: cPanel Metrics on shared plans, terminal tools when you have root.

Frequently Asked Questions

Where are Apache log files located?

By setup: cPanel hosting keeps them in ~/logs/ for the account's domains or the per-domain logs directory in File Manager; a Debian/Ubuntu VPS writes /var/log/apache2/access.log and error.log; a RHEL/CentOS VPS writes /var/log/httpd/access_log and error_log. Virtual hosts can override these paths via the CustomLog and ErrorLog directives.

What's the difference between access and error logs?

The access log records every request Apache processes — client IP, time, path, status code, bytes, referrer and user agent. The error log records failures: Apache faults, startup problems and PHP fatal errors. Access tells you what happened; error tells you why.

How do I read the Apache log format?

Read a combined-format line left to right: client IP, identity (usually -), user (usually -), timestamp in brackets, the quoted request line (method, path, protocol), the status code, the bytes sent, then the quoted referrer and user agent. The decode of each field is in the combined log format section above.

How do I find 404 errors in Apache logs?

Grep the access log for the status — grep ' 404 ' access_log — and read the requested paths that come back; repeated paths are dead links worth fixing. On Apache 2.4 with the default LogLevel warn, routine 404s stay out of error_log, so the access log is the right place to count them.

How long are Apache logs kept?

It depends on rotation, not a fixed rule. Apache's rotatelogs or distro logrotate typically keeps a set number of rotated files (a daily rotation keeping 14 files gives about two weeks). On shared cPanel hosting the host manages rotation; ask support for the exact retention on your plan.

How do I analyze Apache logs for bot traffic?

Group the user-agent field or grep for known crawler names (Googlebot, bingbot, AhrefsBot) and count requests per client IP to see which robots hit hardest. GoAccess turns the same access log into a live dashboard of hits by status, path and agent; cPanel's AWStats gives the same view without SSH.

Is WebJi® an Indian company?

Yes. WebJi® is headquartered in Jaipur, Rajasthan and has operated since 2005. Billing, support and governance all run from India.

Do you provide GST invoices?

Every purchase and renewal gets a GST invoice with our GSTIN, and hosting prices are quoted exclusive of 18% GST. Claim input credit as applicable.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →