记录负载均衡器背后的 Web 服务操作
Logging web services operations behind load balancer
我开发的一些 Web 服务将安装在 4 台不同的服务器上在负载均衡器后面维护会话。
我正在使用 c# 和 log4net。
appender 是一个 RollingFileAppender 和一个 AdoNetAppender。
我阅读了 https://logging.apache.org/log4net/release/faq.html(第 如何让多个进程记录到同一个文件?)
If you use RollingFileAppender things become even worse as several
process may try to start rolling the log file concurrently.
RollingFileAppender completely ignores the locking model when rolling
files, rolling files is simply not compatible with this scenario.
我无法将 RollingFileAppender 与 MinimalLock 一起使用。但是我想从不同的服务器登录到同一个文件。
我更喜欢保留 log4net,但我也对其他解决方案感兴趣(不是 linux syslog 解决方案)。成本不允许商业解决方案。
不幸的是,您会发现从多个进程直接记录到同一个文件并不是一个非常可行的选择。
您有多种选择:
- 登录到不同的文件 - 每个服务器可以有一个单独的文件
- 将所有日志发送到一个应用程序,然后该应用程序将记录到文件中。这将使您的日志记录更加脆弱,需要额外的开发工作。
- 记录到数据库 - 数据库设计为让多个进程同时写入它们
- 记录到日志服务器 - Seq, Stackify Retrace, and Azure Application Insights 是一些强大的解决方案示例,旨在从多个应用程序中提取日志 - 而且您可以获得更好的功能
我开发的一些 Web 服务将安装在 4 台不同的服务器上在负载均衡器后面维护会话。
我正在使用 c# 和 log4net。
appender 是一个 RollingFileAppender 和一个 AdoNetAppender。
我阅读了 https://logging.apache.org/log4net/release/faq.html(第 如何让多个进程记录到同一个文件?)
If you use RollingFileAppender things become even worse as several process may try to start rolling the log file concurrently. RollingFileAppender completely ignores the locking model when rolling files, rolling files is simply not compatible with this scenario.
我无法将 RollingFileAppender 与 MinimalLock 一起使用。但是我想从不同的服务器登录到同一个文件。
我更喜欢保留 log4net,但我也对其他解决方案感兴趣(不是 linux syslog 解决方案)。成本不允许商业解决方案。
不幸的是,您会发现从多个进程直接记录到同一个文件并不是一个非常可行的选择。
您有多种选择:
- 登录到不同的文件 - 每个服务器可以有一个单独的文件
- 将所有日志发送到一个应用程序,然后该应用程序将记录到文件中。这将使您的日志记录更加脆弱,需要额外的开发工作。
- 记录到数据库 - 数据库设计为让多个进程同时写入它们
- 记录到日志服务器 - Seq, Stackify Retrace, and Azure Application Insights 是一些强大的解决方案示例,旨在从多个应用程序中提取日志 - 而且您可以获得更好的功能