Sub topic 10
Using Server Logs and Search Console
This chapter assumes you can read HTTP status codes, know the difference between 301 and 302 redirects, and can run shell commands. Crawlers only find links that exist in your pages. Logs and Search Console show you what real visitors and search engines actually requested, including URLs your crawl never reached, such as old links on other sites.
What each source tells you
| Source | Shows | Limits |
|---|---|---|
| Server access log | Every request, its status code, and often the referrer | Raw text, no history if rotated away |
| Search Console Pages report | URLs Google tried to index and why some were excluded | Delayed by days, lists a sample of URLs |
| Search Console Crawl stats | Googlebot requests grouped by response code | Aggregate counts only |
Finding 404s in the access log
In the common or combined log format, field 7 is the request path and field 9 is the status code. This command lists the 20 most requested URLs that returned 404:
awk '$9 == 404 {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20A high count means many people or bots hit that URL. To find out who links to it, print the referrer, which is field 11 in the combined format:
awk '$9 == 404 && $7 == "/old-page" {print $11}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | headA referrer on your own domain means you should fix an internal link. An external referrer usually calls for a redirect. A referrer of "-" means there was no referrer, as with a bookmark or a typed address.
Change 404 to 301 or 302 to see which redirects are still receiving traffic. Change it to 500 to find server errors.
Reading Search Console
Open the Pages report under Indexing. Look for these reasons:
- Not found (404): Google found the URL, often through a link, and received a 404.
- Soft 404: The page returned 200 but looked like an error or empty page.
- Page with redirect: The URL redirects, so it is not indexed. This is normal for old URLs, but check that the destination is the one you intended.
- Redirect error: A loop, a chain that is too long, or an empty destination.
- Server error (5xx): Your server failed when Google asked for the page.
Click a reason to see example URLs, then use the inspection tool on one to see when Google last crawled it. After you fix a group of URLs, use Validate fix so Google rechecks them. The Crawl stats report under Settings shows whether the share of 404 and 5xx responses is rising.
Combining the two
Logs show everything but do not say which URLs matter to search. Search Console shows what Google cares about, but with delay and sampling. Take URLs that appear in both, then rank them by request count and inbound links. The next chapters cover how to rank and fix them.
Exercise
Your log shows 400 requests per week for /old-page returning 404, and nearly all have an external referrer. Which source confirms whether Google knows about this URL, and what is the likely fix?
Show answer
Search Console confirms it, either through the Pages report listing it under "Not found (404)" or through the URL Inspection tool. Because the links are external and you cannot edit them, add a 301 redirect from /old-page directly to the closest matching page. If the content is gone and has no equivalent, return 410 instead.