How to make Apache logfiles accessible to shared hosting users in real-time

log-filesweb-hosting

I am looking for a solution to make Apache logfiles available to shared hosting in a scure manner and in real-time.
I am running Apache 2.2 on Debian and have Apache configured to keep separate access- and error-logs for each virtualhost in a common directory, i.e. /var/log/apache2, the logfiles are owned by root.adm and have 640 permission.

Right now I have a hacky solution which uses a hourly cronjob to copy the logfiles of all virtualhosts to another directory which is read-only to the user a custom CGI-script runs as. This CGI-script then matches an authenticated user to the virtualhosts he/she owns and offers the logfiles of these virtualhosts for download.
This is bad because I need to keep a separate table for matching authenticated users to their virtualhosts and the logs are only updated every hour.

Best Answer

Write out the logs to a process, and have that process split out the log files as appropriate.

See the apache documentation for "Piped Logs".

Related Topic