http://www.blinkenlights.nl/apache/
Got the idea from here: http://svn.blinkenlights.nl/viewvc.cgi/apache/trunk/apache-2/server/
Prefix every log line with the Server Name responsible for generating the log line.
Access log is easy, just add %v to the Log Format declaration, as follows:
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhostlog CustomLog "|/usr/local/bin/loghandler" vhostlog
The Custom Log statement pipes the lines via stdin to a process spawned and handled by httpd itself. Will respawn if it dies, but be fast and careful.
The Error Log is annoying, though. You can't format that, so use the following source patch to prepend the current Server Name (or - for core pre-startup messages).
--- server/log.c.orig 2007-12-30 23:00:52.000000000 -0600 +++ server/log.c 2008-06-20 19:35:09.000000000 -0500 @@ -559,14 +559,20 @@ } } - if (logf && ((level & APLOG_STARTUP) != APLOG_STARTUP)) { - errstr[0] = '['; - ap_recent_ctime(errstr + 1, apr_time_now()); - errstr[1 + APR_CTIME_LEN - 1] = ']'; - errstr[1 + APR_CTIME_LEN ] = ' '; - len = 1 + APR_CTIME_LEN + 1; + len = 0; + + if (s && ap_escape_errorlog_item(scratch, s->server_hostname, MAX_STRING_LEN - len)) { + len += apr_snprintf(errstr + len, MAX_STRING_LEN - len, "%s ", scratch); } else { - len = 0; + len += apr_snprintf(errstr + len, MAX_STRING_LEN - len, "- "); + } + + if (logf && ((level & APLOG_STARTUP) != APLOG_STARTUP)) { + errstr[len] = '['; + ap_recent_ctime(errstr + 1 + len, apr_time_now()); + errstr[len + 1 + APR_CTIME_LEN - 1] = ']'; + errstr[len + 1 + APR_CTIME_LEN ] = ' '; + len += 1 + APR_CTIME_LEN + 1; } if ((level & APLOG_STARTUP) != APLOG_STARTUP) {
Place this into "/usr/ports/www/apache22/files/patch-server:log.c-ErrorLog-ServerName" to have ports patch automatically.