msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

03 Sep 2008 Using vlogger to split Apache logs

Posted by

Vlogger is a program that handles large amounts of virtualhost logs and splits it to separate files.
This is a short HOWTO to configure it using Apache.

Install vlogger in debian etch

# aptitude install vlogger

Make sure you have working Apache server

Configuring vlogger

Change the LogFormat line (there are multiple LogFormat lines – in this example we will change the one that is named combined) in /etc/apache2/apache2.conf. We must add the string %v at the beginning of it

vi /etc/apache2/apache2.conf

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

Add the following CustomLog line to the same file (you can put it directly after the LogFormat line)

vi /etc/apache2/apache2.conf

CustomLog “| /usr/sbin/vlogger -s access.log /var/log/apache2″ combined

NOTE
We only need one CustomLog directive in our whole Apache configuration. Please disable all other CustomLog directives, especially in your virtual host configurations.

Restart apache

# /etc/init.d/apache2 restart

Vlogger will now create subdirectories in the /var/log/apache2 directory, one per virtual host, and create access logs that contain the current date in the file name. It will also create a symlink called access.log that points to the current log file.

Let’s assume we have two virtual hosts, www.example1.com and www.example2.com. Then this is how the /var/log/apache2 directory will look like:

# ls /var/log/apache2/

www.example1.com/
09022008-access.log
09012008-access.log
access.log -> 09022008-access.log
www.example2.com/
09022008-access.log
09012008-access.log
access.log -> 09022008-access.log

Tags: ,

Comments are closed.