Websites & Hosting

Reading Server Logs for Beginners

Understand each field in a web server log line, find errors and unusual traffic with a few commands, and know what to do about what you see.

Key takeaways

  • The access log records each request, while the error log explains what went wrong inside the server or application.
  • The status code is the fastest filter: 4xx usually points to a bad or refused request and 5xx to a server-side failure.
  • A few pipeline commands can show your most requested pages, most common errors and busiest addresses.
  • IP addresses and user-agent strings are clues that can be shared, changed or faked.
  • Logs contain personal data, so limit access, set a retention period and keep secrets out of web addresses.

A server log is a running record of what your web server did. Each request usually produces one line saying who asked, for what, when and what the server answered. Once you can read one line, you can find broken links, diagnose errors, see what crawlers are doing and spot someone probing your site.

You don't need special software to start. A text editor, a few terminal commands and an idea of what you're looking for will do.

Where the logs live

Location depends on the server and system. These are common defaults:

Server Typical location
nginx on Linux /var/log/nginx/access.log and error.log
Apache on Debian or Ubuntu /var/log/apache2/
Apache on Red Hat family systems /var/log/httpd/
IIS on Windows C:\inetpub\logs\LogFiles\

Shared hosts usually offer logs in the control panel. Managed and serverless platforms show them in a dashboard or command-line tool, often for a limited time. Configuration can move or rename anything, so if a file looks empty, check the server settings. Reading system logs normally requires administrator rights, such as sudo on Linux.

If your site sits behind a proxy or content delivery network, the address in your log may be the proxy's. Servers can be configured to take the visitor address from a forwarded header, but only trust that header from proxies you control or have verified.

Anatomy of an access log line

Many Apache and nginx setups use the "combined" format. Here is a line using documentation addresses:

203.0.113.25 - - [05/Dec/2026:14:02:11 +0000] "GET /products/mug HTTP/1.1" 200 5123 "https://www.example.com/shop" "Mozilla/5.0 (X11; Linux x86_64)"
The parts of a combined log line
203.0.113.25 1 [05/Dec/2026:14:02:11 +0000] 2 GET /products/mug HTTP/1.1 3 200 4 5123 5 https://www.example.com/shop 6 Mozilla/5.0 (X11; Linux x86_64) 7 Client address Where the request came from, or the proxy in front 1 Time Server timestamp with its offset from UTC 2 Request Method, path and protocol version 3 Status How the server answered 4 Size Bytes sent in the response 5 Referrer Page the browser says it came from; may be empty 6 User agent How the client describes itself 7 203.0.113.25 1 [05/Dec/2026:14:02:11 +0000] 2 GET /products/mug HTTP/1.1 3 200 4 5123 5 https://www.example.com/shop 6 Mozilla/5.0 (X11; Linux x86_64) 7 Client address Where the request came from, or the proxy in front 1 Time Server timestamp with its offset from UTC 2 Request Method, path and protocol version 3 Status How the server answered 4 Size Bytes sent in the response 5 Referrer Page the browser says it came from; may be empty 6 User agent How the client describes itself 7

The two hyphens are fields for an identity lookup, rarely used, and the user name from HTTP authentication. Your format may differ or add fields such as request duration, so confirm it in the configuration before relying on column positions. The user-agent parser helps decode the last field.

Know your format before you filter

Open the configuration to see what each line really contains. In nginx, the log_format directive defines named formats and access_log chooses one. In Apache, LogFormat defines them and CustomLog applies one. The standard combined format in Apache is written like this:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

Each % code stands for one field: %h the client host, %t the time, %r the request line, %>s the final status and %b the response size, which shows a hyphen when no body was sent.

It is often worth adding how long each request took. In nginx the variable is $request_time, measured in seconds. In Apache, %D records microseconds. With timing in the log, you can find slow pages as well as broken ones. Add new fields at the end of the line so existing commands that count columns keep working.

Some applications and platforms write structured logs instead, typically one JSON object per line. Those are easier for tools to filter by field name, though a bit harder to read by eye.

Read the status code first

Status codes are grouped by their first digit.

  • 2xx means success.
  • 3xx means redirection or "use your cached copy" (304).
  • 4xx means the request couldn't be fulfilled as sent: 404 not found, 403 forbidden, 401 authentication needed, 429 too many requests.
  • 5xx means the server side failed: 500 general error, 502 bad gateway, 503 unavailable, 504 gateway timeout.

A few 404s are normal. A sudden rise after a redesign suggests moved pages that need redirects. Any cluster of 5xx responses deserves a look in the error log.

Useful commands

On Linux and macOS, these assume the combined format. Watch new lines arrive:

tail -f /var/log/nginx/access.log

Count responses by status code, which is the ninth space-separated field:

awk '{print $9}' access.log | sort | uniq -c | sort -rn

List the paths most often returning 404:

awk '$9 == 404 {print $7}' access.log | sort | uniq -c | sort -rn | head -20

Find the busiest client addresses:

awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -20

Older logs are often rotated and compressed. zcat or zgrep reads them without unpacking.

In Windows PowerShell, you can follow a file and search it:

Get-Content .\access.log -Tail 20 -Wait
Select-String -Path .\access.log -Pattern '" 500 '

The search pattern above fits the combined format. IIS logs use a different layout, with a #Fields header line naming the columns, so read that line first.

Use the error log

The access log tells you that a request failed; the error log often tells you why. Match the two by time. Typical messages and their usual meanings:

  • "Permission denied": the server's user can't read a file or folder.
  • "File not found" or "No such file": a wrong path, missing upload or bad configuration.
  • "Connection refused" to an upstream: the application process behind the web server isn't running or listens elsewhere.
  • "Upstream timed out": the application took too long, often because of a slow query or outside service.
  • "Memory size exhausted": a script exceeded its limit.
  • "No space left on device": the disk is full, which can break many things at once.

Read from the first error in a burst. Later messages are often consequences of it. Your application may keep its own log as well, with stack traces the web server never sees.

Work through a problem

Say visitors report that checkout sometimes fails. A sensible path:

Tracing a reported failure
1 Pin down time and page Ask when it happened and what they clicked 2 Filter the access log Find that path around that time 3 Note the status 5xx, 4xx, slow success or nothing at all 4 Check the error logs Match timestamps and read the first error 5 Fix and watch Confirm new requests succeed Pin down time and page Ask when it happened and what they clicked 1 Filter the access log Find that path around that time 2 Note the status 5xx, 4xx, slow success or nothing at all 3 Check the error logs Match timestamps and read the first error 4 Fix and watch Confirm new requests succeed 5

If nothing appears at all, the request never reached this server. Look at DNS, the CDN, a firewall or the visitor's connection. Mind time zones: logs often use UTC while the report uses local time.

Questions your logs can answer

Beyond fixing errors, logs help with everyday site decisions.

Which broken links matter? Count 404 paths and look at their referrers. A referrer on your own site means you have an internal link to fix. An outside referrer suggests an old address worth redirecting.

Did the redesign lose anything? Compare the most requested paths before and after launch, and check that old addresses answer with a redirect.

Who is crawling the site? Filter by user agent to see which automated clients visit and how often. If one is hammering expensive search pages, you can limit it through robots.txt if it respects that file, or through rate limits if it doesn't.

What is eating bandwidth? Add up response sizes by path. A single large video or download linked from elsewhere can dominate. This command totals bytes per path in the combined format:

awk '{bytes[$7] += $10} END {for (p in bytes) print bytes[p], p}' access.log | sort -rn | head -20

Are visitors really seeing the pages? Logs include bots, monitoring probes and every image and script request, so raw line counts overstate human traffic considerably. Treat them as technical records first and audience measurement only after careful filtering.

Spot unwanted traffic

Public servers receive constant automated probing. Requests for admin pages you don't have, for configuration files such as /.env, or long runs of login attempts from one source are common.

Most of these end in 404 or 403 and need no reaction. Pay attention when a probe returns 200, since that means something answered. Check what the file or script is and whether it should exist. Unknown files receiving POST requests can indicate a break-in; see what to do when your site is hacked.

For floods or password guessing, rate limiting and your host's or CDN's protection tools work better than blocking addresses by hand. A user agent claiming to be a search crawler can be fake; major search engines document ways to verify their crawlers, usually through reverse and forward DNS or published address ranges.

Handle logs responsibly

IP addresses and request paths can identify people. Limit who can read logs, rotate them so they don't fill the disk (logrotate handles this on most Linux systems) and delete them after a period you can justify. Privacy laws in some places treat them as personal data.

Keep passwords, tokens and personal details out of URLs, because query strings are logged in full. Before sharing a log excerpt in a support forum, replace addresses, hostnames and identifiers with placeholders.

Where to go next

Command-line filtering works well for one server and a specific question. As traffic or the number of machines grows, a log analysis tool that collects, indexes and graphs entries saves time. Either way, spend a few minutes reading your logs on a normal day. Knowing what ordinary looks like is what makes the unusual stand out.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Websites & Hosting →

Latest news on this topic