PSGI 日志记录 (Perl)
尽管文档相当匮乏且不明确,而且针对初学者的有效操作指南也很少,但我已经开始喜欢 PSGI,并且目前正在我的一个应用程序中使用它。我想知道如何管理跨多节点应用程序的日志记录?关于 PSGI 日志记录,什么被认为是“最佳实践”?
Despite rather scant and unclear documentation and an effective How-To for beginners, I have grown to like PSGI and am currently using it in one of my applications. What I would like to know is how do I manage logging across a multi-node application? What is considered "best practice" regarding logging in PSGI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 Plack::Middleware::AccessLog 进行日志记录访问和 Plack::Middleware::LogDispatch 用于自定义日志记录。
它们又都使用流行的 Log::Dispatch 模块。
LogDispatch Middleware 文档当前不向您展示如何使用
设置后的日志记录对象。下面是一个示例:
要解决多节点问题,您可以使用 Log::Dispatch: :Syslog 会将日志发送到 rsyslog ,而 rsyslog 又可以将日志数据传递给另一个系统日志 服务器。这样,所有节点都可以记录到单个中央日志服务器。
凭借 Log::Dispatch 的灵活性,您还可以选择记录日志
如果您愿意,可以在本地和远程进行冗余。日志发送到
中央服务器可以被认为是主要的,并且日志记录已完成
如果中央日志服务器处于本地状态,则可以考虑在本地进行备份
下来一点。
使用中央日志服务器有几个优点:
我目前以这种方式使用 Log::Dispach 和 Rsyslog 来自己管理多节点集群。
I recommend using Plack::Middleware::AccessLog for logging accessing and Plack::Middleware::LogDispatch for custom logging.
They both in turn use the popular Log::Dispatch module.
The LogDispatch Middleware docs do not currently show you to how to use
the logging object once it is set up. Here's an example:
To address the multi-node concern, you could then use Log::Dispatch::Syslog which would send logging to rsyslog which could in turn to pass the log data on to another rsyslog server. In this way, all the nodes can log to a single central logging server.
With the flexibility of Log::Dispatch, you also have the option to log
both locally and remotely for redundancy if you like. The logs sent to
the central server could be considered primary, and the logging done
locally could be considered backup in case the central log server is
down for a bit.
Using a central log server has several advantages:
I currently using Log::Dispach and Rsyslog together in this way to manage a multi-node cluster myself.