 |
|
| |
| Introduction
| |
Every request to your web site is recorded in Apache's access log, and every problem in its
error log. Reading these is the most direct way to understand your traffic and to diagnose a
misbehaving site. This page covers where the logs are, how to read them, how they are rotated so they
don't fill the disk, and how to turn them into readable statistics. It builds on
Apache.
| |
| Where the Logs Are
| |
Each virtual host names its own
log files in its configuration (the CustomLog and ErrorLog directives). By convention they
live under /var/log/httpd/ on Rocky Linux and /var/log/ on FreeBSD, with per-site names
such as example.com-access.log and example.com-error.log.
The "combined" access-log format records, for each request, the visitor's IP, the time, the URL
requested, the response code, the bytes sent, the referring page, and the browser — everything a
statistics program needs.
| |
| Reading the Logs
| |
Standard command-line tools cover most of what you need:
$ tail -f /var/log/httpd/example.com-access.log # watch requests arrive live
$ tail -n 50 /var/log/httpd/example.com-error.log # the most recent errors
$ grep ' 404 ' example.com-access.log # find missing-page requests
$ grep ' 500 ' example.com-error.log # server errors to investigate
When a page is broken, the error log is the first place to look — it usually names the
file and line at fault. A Perl
one-liner can summarize an access log (for example, the busiest client IPs) in a single command.
| |
| Rotating the Logs
| |
Left alone, logs grow without bound. Both systems rotate them automatically — compressing old
logs and discarding the oldest — but you control the policy per site:
FreeBSD uses newsyslog: add a line to /etc/newsyslog.conf (or a file in
newsyslog.conf.d/) naming the log, the owner, mode, how many to keep, and the size or time at
which to rotate.
Rocky Linux uses logrotate: drop a file in /etc/logrotate.d/ for the site
(the httpd package already ships a sensible default for the standard log directory).
| |
| Turning Logs into Statistics
| |
Raw logs are hard to read in bulk; a log analyzer turns them into tables and charts of pages, visitors,
referrers, and search terms. Several options, from lightest to most interactive:
Analog (FreeBSD) or
Webalizer (Rocky Linux) — extremely lightweight, single config file, static HTML report.
AWStats — richer monthly summaries, run from
cron.
GoAccess — a modern, interactive dashboard, live in the terminal or as HTML.
|
NOTE: Statistics reports contain visitor IP addresses and search terms — put
the report directory behind a password (Apache HTTP Basic authentication) rather than
publishing it openly.
|
| |
| Documentation
| |
See newsyslog.conf(5) on FreeBSD and logrotate(8) on Rocky Linux, and Apache's logging
documentation:
|
Toll Free 1-866-GSP-4400 • 1-301-464-9363 • service@gsp.com
Copyright © 1994-2026 GSP Services, Inc.
|