Catch SysLogHandler's output

2019-08-04 09:07发布

问题:

Following advice, I'm planning to log errors from several time critical python processes (clients) to a single logging process (server). SysLogHandler seems to be the correct choice as it uses UDP (I rather be system-agnostic) and does not wait for any confirmation, and as I'm using localhost so there should practically be no loss of logs.

However, I'm unclear as to how I should implement the server side on two accounts:

  • Should I simply open a multiprocessing.connection and conn.recv() the log as text?
  • Is there a way to handle the error as a log on the server side, thus printing it using other logging.handlers? Or is it just plain strings at that point?

A nice use-case would be for the time critical processes to send errors to the logging process which in turn would use SMTPHandler to send these errors via email...

回答1:

Well, to continue with advices ( ;) ), take a look to rsyslog, this is the most powerfull syslog server I know. It support threaded logging facilities, massive load and mail sending.