I have multiple Apache servers and I want to centralize their access logs. I wonder if I can use named pipes and netcat for that, however I am afraid that 2 things may happen:
The central log will be unreadable because if 2 servers happen to write to the log at the same time netcat will just merge the 2 log lines. For example first log line will be written in half and then the other one starts. So the question is whether netcat has some sort of protection against this race condition?
If netcat crashes the Apache process will get blocked since it will not be able to write to the named pipe anymore, since no process will be reading from this pipe. Is this a valid concern?
The setup that I am planning looks like this:
On the shared storage server I will run something like
nc -l [port_number] > shared_access_log
On every machine with Apache I will run something like
nc [ip_of_shared_server] [port_number] < [path_to_named_pipe]
Then I will point every Apache server access log to the named pipe.
Regarding my first concern with the mixed log entries I was thinking of writing a simple server on the shared server which will make sure to write the log entries in order of accepting them from each of the other servers. But I am not sure whether this is actually necessary.
Thanks!