spreading a single request over multiple access logs impossible with lighttpd?

It seems that lighttpd can't spread one HTTP request over multiple, possibly differently formatted access logs. At least I couldn't find anything in mod_accesslog's documentation or with some quick Google searches.

This is an example of how to specify the format and destination for access logging:

accesslog.filename = "/var/log/lighttpd/access.log"
accesslog.format = "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""

You may notice that there are just the two variables accesslog.filename and accesslog.format, only referencing "the" access log instead of several individual ones, and that the assigned values are strings, not lists (I tried specifying lists, lighttpd doesn't accept them).

Now, spreading different, individual HTTP requests over multiple log files is still possible. For example, you might want to log request for different virtual hosts into different log files, an intention which is quite common. To do this, simply use lighttpd's conditional configuration syntax, something which I like very much about lighttpd, and reassign different values to accesslog.filename (and/or accesslog.format):

$HTTP["host"] == "example.com" {
accesslog.filename = "/var/log/lighttpd/example.com-access.log"

But it seems that you can't log the same HTTP requests to multiple destinations. Perhaps you want to have one big access log that contains every request for every virtual host and several specific access logs that each contain requests to an individual virtual host. Or you want to have two access logs which contain exactly the same requests, but with different formats.

I did the latter one under apache, in order to log more information for debugging purposes, without disrupting the scripts that gather statistics from the common access logs. That's how I discovered lighttpd's apparent lack of ability to do so.

One workaround would be to pipe into a script instead of writing directly into a file, which lighttpd supports out of the box:

accesslog.filename = "|/path/to/some/log-script"

But that's adding an additional layer of complexity and you can't easily use lighttpd's conditional configuration to decide on the destination anymore. Additionally, in the above debugging scenario where different log files contain the same requests but with different formats, you'd have to specify the set union of all format options in your lighttpd configuration and parse and reformat inside of your script.

Is there anything I have overlooked or are there any plans for future lighttpd versions?

No comments: