1

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"

2 Answers 2

1

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" 
1

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.

You must log in to answer this question.

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