Splitting Lighttpd logs with vlogger and creating statistics with Webalizer

Vlogger is a little tool with which you can write lighttpd logs broken down by virtual hosts and days. With vlogger, we need to put just one accesslog.filename directive into our global lighttpd configuration, and it will write access logs for each virtual host and day.

Step 1: Setting up Lighttpd

      #### accesslog module
      accesslog.filename = "| /usr/sbin/vlogger -s access.log /var/log/lighttpd"
      accesslog.format = "%v %h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
      
Please disable all other accesslog.filename and accesslog.format directives in your lighttpd configuration, especially in the vhost configurations! The advantage of writing just one access log is that this lowers the load on the server a lot, especially if you have some high-traffic sites on your server.

Step 2: Running Webalizer

      /usr/bin/webalizer -c /etc/webalizer/webalizer.conf -n www.example.com -s www.example.com -r www.example.com 
      -q -T -o /var/www/www.example.com/web/stats /var/log/lighttpd/www.example.com/`/bin/date -d "1 day ago" 
      +%m%d%Y`-access.log
      

Step 3: Script to automate webalizer runs

      #!/bin/sh
      
      logdir=/var/log/lighttpd
      webalizerconf=/etc/webalizer/webalizer.conf
      yesterdaysdate=`/bin/date -d "1 day ago" +%m%d%Y`
      
      cd ${logdir}
      for directory in *
        do
          if [ -d ${directory} ]; then
            /usr/bin/webalizer -c ${webalizerconf} -n ${directory} \
            -s ${directory} -r ${directory} -q -T -o /var/www/${directory}/web/stats \
            ${logdir}/${directory}/${yesterdaysdate}-access.log
          fi
      done
      
      exit 0
      
howto by nilicule (moc.elucilin@elucilin)
last update: 20th of July 2008