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

We are working towards load balancing our amazon ec2 web servers running apache2. Until we get a better log system in place, we would like to have each instance simply write their server logs to a shared volume (shared using sshfs atm)

The problem we ran into is that if two instances are writing to the same shared log file (/shared-volume/access.log) some of our logs are clobbered due to the lack of file locking by sshfs

Since we want instances to be identical to each other, the short-term solution we thought of was to have apache log to /shared/log/apache2/[instance-ip]-access.log

Is this possible?

Tried this and other variants, but it seems the logfile is always statically interpreted.

CustomLog /shared/log/apache2/%{SERVER_ADDR}-access.log "%h %l %u %t \"%r\" %>s %b %D"
share|improve this question

2 Answers 2

up vote 1 down vote accepted

This actually seems to work, are there any downsides?

CustomLog "|cat >> /shared/log/apache2/`hostname`-access.log" "%h %l %u %t \"%r\" %>s %b %D" 
share|improve this answer

Would it be possible to move the interpretation back a step, perhaps to the mount command? Bash will turn "$HOSTNAME" into the hostname. Instead of logging to /shared/log/apache2/, log to /shared/log, but make sure /shared/log is actually ssh-host:/var/log/apache/$HOSTNAME/. That way you can keep your configs identical.

share|improve this answer

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.