How often does the letter "l" occur in:
Q: Apache single ErrorLog, many VirtualHosts I have a webserver with many (thousands) VirtualHosts. With the current configuration, Apache fills 2 files for each VirtualHost: error.log + access.log. Apache works in prefork mode and to avoid to many file descriptors opened at the same time, I would like to have a single access.log and error.log for all VirtualHosts.
A CRON task will split files for each VirtualHost once a day, so I need the VirtualHost name on each line of the *.log files. This is pretty easy for access.log:
LogFormat "%V:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
CustomLog /var/log/apache2/vhosts_access.log vhost_combined

%V gives me the VirtualHost name and that's enough for splitting files.
But I just can't find the equivalent setting for ErrorLog.
Questions:


*

*in your opinion is it relevant to
try to identify each the origin of
each error.log line

*do you know a solution?


A: ErrorLog directive in Apache can not be customized.
If your intention is to reduce FDs, the with a single access log, an thousands of virtualhosts, you will reduce them (FDs) by at least n*virtualhosts.
My suggestion is to keep error log for each VH and as you say, split your access log as you are already doing it.
If it is as MUST to configure a single error log, each entry in error_log has a corresponding entry in access_log, so with some perl magic you could get the job done, but I think it is not worth the effort, as it would take some time to process and it is very error prone.

A: You could use an ErrorLog directive with a pipe to a one-line bash script - i.e.
ErrorLog "| /script_location 'log destination' 'virtualhost.com'"

... to the script:
#!/bin/bash
read INCOMING_LOG && echo ${2}" - "${INCOMING_LOG} >> $1


user
I counted 71 "l"s in that text.
assistant