Apache Logging via ServerAlias
My last problem with Plesk was a side-effect of working around its thirty domain limit using Apache's ServerAlias
and Drupal's multisite configuration. By doing so, all log data was being sent to a single file which made it impossible for me to tease out individual domain stats. The standard solution - using an Apache LogFormat
with %v
preprocessed via split-logfile - didn't work because %v
only covered ServerName
, not ServerAlias
.
I had initial success swapping out %v
for %{Host}i
, but another problem arose: %{Host}i
happily reports subdomains, which split-logfile then cheerful sends to independent logfiles. That may work for some folks, but the www/no-www problem still rears its ugly head. I eventually settled on using SetEnvIf
along with CustomLog
:
SetEnvIf HOST "^(.*\.)?(disobey|ghostsites)\.com" log_disobey
SetEnvIf HOST "^(.*\.)?(secretsite)\.com" log_secretsite
CustomLog /statistics/logs/disobey.com-access_log combined env=log_disobey
CustomLog /statistics/logs/secretsite.com-access_log combined env=log_secretsite
Plesk will include extra directives like the above if you stick them in /var/www/vhosts/disobey.com/conf/vhost.conf
and restart Apache. The above approach gives me lots of leeway - here I'm sending all subdomains (or lack thereof) to the same files, and also combining multiple domains into one as needed.
Now it's just a simple matter of adding a new /etc/logrotate.d/
config for these new logs and pointing a log analyzer at 'em (I like Analog because you can shut off all the gay-ass pie charts). Another nice side-effect of the above is we're not touching Plesk's default vhost logs or Webalizer: I'll still be able to see a collected view of all my server names and aliases as before.