捕获 SysLogHandler 的输出
遵循建议,我计划将多个时间关键的Python进程(客户端)的错误记录到单个日志进程(服务器) )。 SysLogHandler 似乎是正确的选择,因为它使用 UDP(我宁愿与系统无关)并且不等待任何确认,并且由于我使用的是 localhost ,所以实际上应该不会丢失日志。
但是,我不清楚如何在两个帐户上实现服务器端:
- 我应该简单地 以文本形式打开
multiprocessing.connection
和conn.recv()
日志? - 有没有办法在服务器端将错误作为日志处理,从而使用其他logging.handlers打印它?或者此时它只是普通的字符串?
一个很好的用例是时间关键的进程将错误发送到日志记录进程,而日志记录进程又会使用 SMTPHandler 通过电子邮件发送这些错误...
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
andconn.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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,要继续提供建议 (;)),请查看 rsyslog,这是我所知道的最强大的系统日志服务器。
它支持线程日志记录工具、海量负载和邮件发送。
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.