Azure 节点 Web 应用程序 - 访问日志记录数据
Azure Node Web App - Accessing Logging Data
如何在部署到 Azure 的 NodeJS 站点中 "console.log()" 并实际访问日志而不只是转储到 blob 存储?我们尝试了几种方法,但找不到一种可以轻松访问日志的方法。
我们尝试过的:
Table 存储
我们已经通过门户打开了 table 存储,但它没有获取任何东西。对于 .NET 应用程序,我们可以使用 TRACE 语句并且效果很好。
IISNode/Kudu
我们已经配置了一个 iisnode.yml 文件,其中
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs.3.0\node.exe"
loggingEnabled: true
devErrorsEnabled: true
并在我们的网络配置文件中添加了一条规则。
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode"/>
</rule>
这似乎将数据转储到 Kudu 中的某些文件,可从以下位置访问:
https://sitename.scm.azurewebsites.net/DebugConsole
文件位于:Home\Application\LogFiles
但是...您如何在不下载的情况下访问 index.html 文件???即使在拉动它之后......它非常难以阅读并且不是很有帮助。
所以,问题:
如何在 Azure 中配置节点日志记录,以易于阅读的方式提供日志?
您是否尝试过为您的 nodejs 应用程序启用诊断日志?
Enable diagnostics logging for web apps in Azure App Service
不下载日志就看日志,你试过日志流吗?
据我所知,Azure NodeJS WebApp 上的 console.log
函数会将信息级别的日志记录写入 Kudu 路径 D:\home\LogFiles\Application\
中与模式 *-stdout-*.txt
匹配的文件中。
您可以尝试通过访问 url https://<your_webapp_name>.scm.azurewebsites.net/api/vfs/LogFiles/Application/ 获取 Kudu 路径 \LogFiles\Application\
中日志文件的 json 列表,并过滤匹配的项目模式 *-stdout-*.txt
并在编程中获取它们。
读取日志的简单方法是访问 url https://<your_webapp_name>.scm.azurewebsites.net/api/vfs/LogFiles/Application/index.html,即 Kudu 中 index.html
文件的 url。然后可以点击日志link浏览日志。
或者您可以尝试通过在 Kudu Site extensions
标签页 Site extensions
标签页 Gallery
中搜索单词 logs
来安装名为 Azure Web Site Logs Browser
的扩展程序,然后您可以通过 url https://<your_webapp_name>.scm.azurewebsites.net/websitelogs/.
读取 File System - Application Logs
中的日志
如何在部署到 Azure 的 NodeJS 站点中 "console.log()" 并实际访问日志而不只是转储到 blob 存储?我们尝试了几种方法,但找不到一种可以轻松访问日志的方法。
我们尝试过的:
Table 存储
我们已经通过门户打开了 table 存储,但它没有获取任何东西。对于 .NET 应用程序,我们可以使用 TRACE 语句并且效果很好。
IISNode/Kudu
我们已经配置了一个 iisnode.yml 文件,其中
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs.3.0\node.exe"
loggingEnabled: true
devErrorsEnabled: true
并在我们的网络配置文件中添加了一条规则。
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode"/>
</rule>
这似乎将数据转储到 Kudu 中的某些文件,可从以下位置访问:
https://sitename.scm.azurewebsites.net/DebugConsole
文件位于:Home\Application\LogFiles
但是...您如何在不下载的情况下访问 index.html 文件???即使在拉动它之后......它非常难以阅读并且不是很有帮助。
所以,问题:
如何在 Azure 中配置节点日志记录,以易于阅读的方式提供日志?
您是否尝试过为您的 nodejs 应用程序启用诊断日志?
Enable diagnostics logging for web apps in Azure App Service
不下载日志就看日志,你试过日志流吗?
据我所知,Azure NodeJS WebApp 上的 console.log
函数会将信息级别的日志记录写入 Kudu 路径 D:\home\LogFiles\Application\
中与模式 *-stdout-*.txt
匹配的文件中。
您可以尝试通过访问 url https://<your_webapp_name>.scm.azurewebsites.net/api/vfs/LogFiles/Application/ 获取 Kudu 路径 \LogFiles\Application\
中日志文件的 json 列表,并过滤匹配的项目模式 *-stdout-*.txt
并在编程中获取它们。
读取日志的简单方法是访问 url https://<your_webapp_name>.scm.azurewebsites.net/api/vfs/LogFiles/Application/index.html,即 Kudu 中 index.html
文件的 url。然后可以点击日志link浏览日志。
或者您可以尝试通过在 Kudu Site extensions
标签页 Site extensions
标签页 Gallery
中搜索单词 logs
来安装名为 Azure Web Site Logs Browser
的扩展程序,然后您可以通过 url https://<your_webapp_name>.scm.azurewebsites.net/websitelogs/.
File System - Application Logs
中的日志