Azure 应用服务:从所有缩放的机器访问日志

Azure AppService: Accessing logs from all scaled machines

给定 Azure AppService 部署,运行 已扩展到 6 个实例的 WebAPI 应用程序。

我们的 WebAPI 应用程序使用 NLog 和文件追加程序写入诊断日志。有没有办法通过 Azure 门户或 Kudu 检查这些日志文件?

我注意到 Kudu 可以访问沙箱中的文件系统...但是当应用程序扩展到 6 个实例时,沙箱似乎只查看第一个实例。

有什么方法可以访问其他 5 个实例中的任何一个的日志文件吗?

Is there any way to access the log files on any of the other 5 instances?

所有实例共享日志文件路径。 详情请参考Azure WebApp SandBox and Azure WebApp File Access.

Every Azure Web App has a home directory stored/backed by Azure Storage. This network share is where applications store their content. The home directory is shared among all instances so that all instances see the same directory

正是出于这个原因,我们放弃了 NLog。 Azure 本机支持使用本机 .Net Trace 记录到 Azure 存储,您将在每个实例的存储上存储所有日志。

如果您真的希望保留 NLog,可以将日志名称配置为包含 ${machinename} 或 processid