【问题标题】:Azure application logging(blob) for node.js deployed as app service部署为应用服务的 node.js 的 Azure 应用程序日志记录(blob)
【发布时间】:2017-03-13 21:39:01
【问题描述】:

我已将节点应用程序部署为 azure app 服务。并启用了具有日志级别“详细”的 azure Application Logging(blob) 并链接了 blob 类型的存储帐户。但是我的 node.js console.log 和 console.error 没有出现在 blob 中。我仍然继续在文件系统日志中获取 stdout 和 stderr 文件。

我的 iisnode.yml 文件有以下内容-

nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\6.3.0\node.exe"
nodeProcessCountPerApplication: 2
loggingEnabled: true
logDirectory: iisnode
maxLogFiles: 100
devErrorsEnabled: true
configOverrides: "iisnode.yml"
asyncCompletionThreadCount: 20
flushResponse: true

【问题讨论】:

  • 不支持此功能非常令人沮丧。有同样的问题,现在我已经在猜测 nodejs 是否是 azure 堆栈上的一等公民。应用程序日志记录到文件系统会在 12 小时后自动关闭,因此您必须使用像 winston 这样的适配器,这似乎适得其反。
  • 请注意,登录到 Azure blob 的成本不可忽略。如果您的应用程序每秒写入一次日志,仅写入操作每月将花费您 16 美元。

标签: azure logging azure-web-app-service


【解决方案1】:

我现在正在尝试做同样的事情and came across this:

对于 node.js 网站,写入应用程序日志的方式是使用 console.log('message') 和 console.error('message') 写入控制台,这会转到信息/错误级别的日志条目。目前,node.js 的日志文件唯一支持的目标是文件系统。

您似乎无法将 blob 存储用于 Azure Web 应用程序中的应用程序日志。然而,流行的 nodejs 记录器(例如 winston)有 Azure blob 存储适配器: winston-azure-blob-transport

【讨论】:

  • winston-azure-blob-transport 运行良好。我当前的解决方案是覆盖console.log/error,调用原始方法以及使用winston 记录到blob 存储。
猜你喜欢
  • 2018-01-26
  • 2017-10-17
  • 2017-09-12
  • 2021-04-23
  • 1970-01-01
  • 2018-04-09
  • 1970-01-01
  • 1970-01-01
  • 2020-04-22
相关资源
最近更新 更多