Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Apache 2 with VirtualHosts and currently, I'll have to add ErrorLog/CustomLog manually for each new vhost (I know I could use a script to create them).

Is there a way to define those directives in the normal apache2 config, so that for each vhost, so that the log directives are automatically set depending on the ServerName, or do I have to create those seperately for each vhost?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

See this answer: Wildcards in Virtual Hosts with dynamic logs?

The short answer is no, you can't have some sort of dynamic ErrorLog definition that will create separate logs for each virtual host through a single ErrorLog setting, but you can do some tricks for CustomLog to add the virtual host to the log, and then pipe the output to a script to parse the data out and write to distinct log files.

I think all of that is relatively complex, though. I would write a script that generates per-vhost configuration files into a specific directory, each with their own ErrorLog and CustomLog directives, and then use Include to include that directory's files into the overall configuration. Make the script run and complete just before every server start, restart, or HUP.

The other option is to code an Apache module that introduces a configuration directive that allows you to do what you want.

share|improve this answer
    
Too bad, but thanks for your help. –  Femaref Feb 10 '13 at 17:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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