Skip to Main Content
Linux System Administration
book

Linux System Administration

by Tom Adelstein, Bill Lubanovic
March 2007
Intermediate to advanced content levelIntermediate to advanced
304 pages
11h 12m
English
O'Reilly Media, Inc.
Content preview from Linux System Administration
Logfiles
|
141
All those % things stand for Apache configuration variables; for example, %h means
hostname. The combined format is just the common format plus the referer and the
user agent (browser). Unfortunately, neither format includes the name of the virtual
host (a
%v variable), which you need to split the log by host. Therefore, if you want to
do this you’ll need to define a new logfile type.
Rather than getting your fingerprints all over the master Apache configuration file,
continue to make your changes to the site file we’ve been using thus far (/etc/
apache2/sites-enabled/000-default). Put these lines above any of your
VirtualHost
directives:
# Define a new virtual host common log format:
LogFormat "%v %h %l %u %t \"%r\" %s %b" vcommon
Splitting Logs with vlogger
You may be wondering whether to split lines of logging information into separate
files as Apache is being accessed, or to split the access file once a day with a utility
such as Apache’s split-logfile. We prefer the first option, because it diverts the lines
into the proper access logs immediately, and we don’t need to write cron jobs. A
good splitter is the vlogger program. Apache allows you to pipe the log through some
external program, which is just what we want. Add this right below the
LogFormat
line you just entered:
# Split log on the fly into virtual host directories
# under /var/log/apache2:
CustomLog "| /usr/sbin/vlogger -s ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux System Administration

Mastering Linux System Administration

Christine Bresnahan, Richard Blum
Mastering Linux Administration

Mastering Linux Administration

Alexandru Calcatinge, Julian Balog

Publisher Resources

ISBN: 9780596009526Supplemental ContentCatalog PageErrata