1

So, I've been using cronolog for years with this directive:

<VirtualHost *:80>
  SetEnv origin SND
  ServerName sandman.net
  CustomLog "|/usr/bin/cronolog [..]/logs/SND/log_%Y-%m.txt" combined
</VirtualHost>

Problem is that with a lot of virtual hosts, I suddenly reach my maximum of open file descriptors when apache is spawning cronolog.

With some googling (and searching here) I've found no solution for this, so is there none? As you can see, I set an ENV variable in Apache to "SND" for that vhost, what I would LIKE to do is something like this:

CustomLog "|/usr/bin/cronolog [..]/logs/${origin}/log_%Y-%m.txt" combined
<VirtualHost *:80>
   SetEnv origin SND
   ServerName sandman.net
</VirtualHost>

Which, theoretically, would spawn just one cronolog process that writes to the correct vhost log file.

But it seems that the pipe commend isn't parsed for Apache variables in any stage of the process, which means that the only solution that I can see is that I add ${origin} to the LogFormat and then write my own log rotate script that will parse out (and ignore) the vhost variable and then write the rest of the log line to the appropriate file. But will this be less overhead?

Any other suggestions?

2 Answers 2

1

There always will be one instance of cronolog for each open log file. One solution is here: http://httpd.apache.org/docs/2.2/logs.html#virtualhost It suggests to just add vhost name to log file and then split it into separate files, if needed.

Other possible solution, that you suggested: write your own program/script that will split logging into per-vhost logs. Also it may be a good idea to send all to syslog and run splitting program on syslog host. In this way apache will hold open only one file descriptor for each log type. Naturally, there will be some overhead, but apache will not run out of file descriptors limit.

0

maybe you could use a named pipe.

generally gelraen's suggestion is pretty good, but if you do it you will miss the rotation (you could call cronolog from syslog, but then some extra queues may be needed in order to reduce the overhead)

http://httpd.apache.org/docs/2.2/vhosts/fd-limits.html (taken from gelraen)

except for that, maybe it's a good time to distribute your virtual hosts. even if you cannot afford a real machine, you could use a virtual one. But i don't think that having everything on a single server is a good idea.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .