繁体   English   中英

如何使用Azure资源管理器在Azure Web应用程序中设置应用程序日志

[英]How to set the application log in an Azure webapp using Azure resource manager

有谁知道如何使用Azure资源管理器(Powershell或JSON)在Azure Web App上设置以下诊断设置。

在此输入图像描述

使用.json我只能找到这些设置

     "requestTracingEnabled": true, /* Failed request tracing, aka 'freb' */
     "httpLoggingEnabled": true, /* IIS logs (aka Web server logging) */
     "logsDirectorySizeLimit": 40, /* 40 MB limit for IIS logs */
     "detailedErrorLoggingEnabled": true, /* Detailed error messages  */

这将打开Web服务器日志记录到文件系统,但不打开应用程序日志记录或blob存储。

使用Powershell,此命令似乎只适用于ASM,因为它找不到非经典存储帐户

   Enable-AzureWebsiteApplicationDiagnostic

任何帮助,将不胜感激。 我们目前正在使用Azure Powershell 0.9.8

问候

用于根据上面的屏幕截图配置应用程序日志(Blob)和Web服务器日志记录(存储)的Azure Resource Manager (ARM) template json部分如下所示:

{
  "apiVersion": "2015-08-01",
  "name": "logs",
  "type": "config",
  "dependsOn": [
    "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
  ],
  "properties": {
    "applicationLogs": {
      "azureBlobStorage": {
        "level": "Information",
        "sasUrl": "<Your Azure Blob Storage Account SAS Url>",
        "retentionInDays": null
      }
    },
    "httpLogs": {
      "azureBlobStorage": {
        "sasUrl": "<Your Azure Blob Storage Account SAS Url>",
        "retentionInDays": null,
        "enabled": true
      }
    },
    "failedRequestsTracing": {
      "enabled": true
    },
    "detailedErrorMessages": {
      "enabled": true
    }
  }
}

参考: AzureWebsitesSamples / ARMTemplates / WebAppManyFeatures.json

希望这能回答您的问题并帮助您解决问题。

如果您需要进一步的帮助或澄清,请告诉我。

如果您在资源浏览器中浏览现有的Web应用程序,您将找到如下所示的config/logs部分:

{
  "id": "/subscriptions/.../config/logs",
  "name": "logs",
  "type": "Microsoft.Web/sites/config",
  "location": "North Central US",
  "properties": {
    "applicationLogs": {
      "fileSystem": {
        "level": "Off"
      },
      "azureBlobStorage": {
        "level": "Information",
        "sasUrl": "...",
        "retentionInDays": 14
      }
    },
    ...
}

我相信您可以在json模板中使用此格式来配置日志记录。 (此部分将是config/web部分的兄弟,其中包含问题中提到的设置。)

请注意,虽然System.Web架构中没有描述config/logs部分,因此我认为MS目前不支持。 我很确定我已经尝试过,但看到它有效。

我没有找到如何在第一个提供的模板中设置它。 但在配置资源后,结果很简单。 请参阅https://stackoverflow.com/a/51617949/511144上的答案,了解使用Set-AzureRmResource的实际脚本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM