My question may be a bit confusing, and sorry for that. Here is what i need:

Well, i have (let's say) 3 Websites hosted on one Apache (which are defined inside each VirtualHost settings. Then i currently log their Access Logs separately as in:

  • /var/log/httpd/website-a.com.access_log
  • /var/log/httpd/website-b.com.access_log
  • /var/log/httpd/website-c.com.access_log

So it is all fine. But at the same time, i ALSO want them (all the access logs) inside the Apache's default localhost log file (i'm not sure how to call that one). May be:

  • /var/log/httpd/access_log (I think this is default one)

In other words, is there a way to (how to) keep the Access Logs in the separated manner, and at the same time, keep all in the same combined file also?

So this will allow me to see each of the Access Logs in their separated files. And at the same time, i can see all the logs in one place also IF I NEED TO.


This can be done. Instead of creating a CustomLog entry in each VirtualHost section, use SetEnvIfNoCase in the global config httpd.conf to set a variable if the domain matches and then log that variable enabled entry to a file.


SetEnvIfNoCase Host website-a.com weba
SetEnvIfNoCase Host website-b.com webb
SetEnvIfNoCase Host website-c.com webc

CustomLog /var/log/httpd/website-a.com.access_log combined env=weba

and so on. Of course, you will have to account for variations of your domains names, possibly using regex if required should you need to be more specific about sub-domains.

[edit] You may need to escape the dot in the domain name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.