I'm using mod_userdir on Apache 2.2 to give multiples users access to a web server (for their tests and other stuff).
I would like to give my users access to apache logs (so that they can debug their scripts) but log entries (both ErrorLog
and CustomLog
: error.log and access.log) are combined together (whatever "user" directory is concerned).
Is there a way to separate log into multiple files (depending of the user).
Apache version : 2.2.16
"/etc/apache2/sites-enabled/000-default" config file:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
"/etc/apache2/mods-enabled/userdir.conf" config file:
<IfModule mod_userdir.c>
UserDir /home/*/public_html
UserDir disabled root
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Options
Options MultiViews Indexes IncludesNoExec
IndexOptions FoldersFirst FancyIndexing IgnoreCase
php_admin_value open_basedir "..:/usr/share/php/"
</Directory>
ErrorLog /tmp/apache2-userdir-error.log
LogLevel warn
CustomLog /tmp/apache2-userdir-access.log
</IfModule>
According to Apache CustomLog Directive manual (mod_log_config module), a program can be specified instead of a file, this program will receive log into it's STDIN.
One could then easily parse that log message to check from which path the message is for (thus which user) and write it to a specific file (named by the user name for instance).
Hmmm... I'm 99% sure that you can use regex capture groups on "SetEnvIf" to do this...
I did something similar -- I split the user logs (all of them) off from the website logs using the following:
You should be able to do: