We help IT Professionals succeed at work.

Logfile depending on host in httpd.conf

olbion
olbion asked
on
243 Views
Last Modified: 2010-03-04
Hi,

Is there any way that I can code httpd.conf so that the log files automatically inlude the name of the host? I know I can do this by setting up separate virtual hosts, but the problem with this is that I would have to include many, identical lines of rewrite rules for each virtual host. It would be better if I could do something like

ErrorLog /path/%{HTTP_HOST}_error_log

Alternatively, some sort of if/then structure to assign different log files to different hosts. Is this possible?

As another alternative, would it be possible to include a file into httpd.conf containing all the rewrite code, and include that in every virtual host?
Comment
Watch Question

AFAIK you can use environment variables here, so if you have set MYHOST before starting apache you should be able to use %{MYHOST}

Author

Commented:
Hi,

How do you mean having set the variable before starting apache? Outside of httpd.conf? How could it be set?
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
So you are talking about general system variables? That is, one system=one host? In that case, it will not help me. My server can be accessed using various hosts. What I want is a setup so that, depending on what host is used, a different log file is used.
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
>  My server can be accessed using various hosts.
then you have virtual hosts, otherwise it could not serve these various hosts simulatneously
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.