Home > General Articles > Lighttpd – Separate log files for each vhost

Lighttpd – Separate log files for each vhost

November 10th, 2009 Leave a comment Go to comments

I could not resist digging into my administrative and shell experience when I saw that somebody wrote a php script to dynamically split lighttpd logs. Hmm I use php for more complicated stuff.

I achieved this by putting the following into lighttpd.conf

accesslog.filename          = "|/usr/bin/splitlog.sh"


The following is the listing for splitlog.sh, shell veterans, please comment if I am overdoing this. Since my exposure is of very low.

#!/bin/bash

logDir="/var/log/lighttpd"

cat - | while read line
 do 
   dom=$(echo $line | cut -f2 -d" ")
   echo $line >> $logDir/${dom}-access.log
 done

  1. c_schmitz
    July 28th, 2010 at 02:20 | #1

    Thank you! This helped alot ;). With several thousand subdomains you don’t want to define a log for each vhost ;)

  1. No trackbacks yet.

eighty nine − = eighty six