0

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:

  1. 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?

  2. 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!

Thomas
  • 4,225
  • 5
  • 23
  • 28
raxbg
  • 1
  • 5
    That seems a bit too much DIY and I don't think that would be very robust either. The more traditional way to centralise your logs is to log to syslog and configure syslog to log to a remote syslog server and more modern is to consider something like [filebeat](https://www.elastic.co/products/beats/filebeat) – HBruijn May 17 '18 at 09:41
  • Thanks, I prefer some freeware for the job though. I am looking for something simple to setup. Can you recommend anything? – raxbg May 17 '18 at 15:43
  • 1
    Both syslog and filebeat are 'freeware'. – toppledwagon May 17 '18 at 18:14

0 Answers0