使用ARM模板启用App Service的诊断日志

时间:2018-09-19 09:34:18

标签: azure azure-web-app-service arm-template azure-diagnostics

我正在尝试使用门户网站为应用程序服务启用启用诊断日志,如下所示:

enter image description here

我尝试使用ARM模板创建的相同设置,但不起作用。 我的ARM模板如下所示:

enter image description here

设置或任何其他启用日志的方式是否有问题? 感谢任何人的帮助。

关于, 迪蒂·马米达拉(Dipti Mamidala)

2 个答案:

答案 0 :(得分:0)

在要为其启用诊断日志的资源的资源数组中,添加类型[resource namespace]/providers/diagnosticSettings的资源。

示例:

"resources": [
  {
    "type": "providers/diagnosticSettings",
    "name": "[concat('Microsoft.Insights/', parameters('settingName'))]",
    "dependsOn": [
      "[/*resource Id for which Diagnostic Logs will be enabled>*/]"
    ],
    "apiVersion": "2017-05-01-preview",
    "properties": {
      "name": "[parameters('settingName')]",
      "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
      "eventHubAuthorizationRuleId": "[parameters('eventHubAuthorizationRuleId')]",
      "eventHubName": "[parameters('eventHubName')]",
      "workspaceId": "[parameters('workspaceId')]",
      "logs": [ 
        {
          "category": "/* log category name */",
          "enabled": true,
          "retentionPolicy": {
            "days": 0,
            "enabled": false
          }
        }
      ],
      "metrics": [
        {
          "category": "AllMetrics",
          "enabled": true,
          "retentionPolicy": {
            "enabled": false,
            "days": 0
          }
        }
      ]
    }
  }
]

documentation

中了解更多信息

更新:要使用以下示例设置Web Server logging的值

             "properties": {
                "applicationLogs": {
                  "Storage": {
                    "level": "Verbose"
                  }
                },
                "httpLogs": {
                  "fileSystem": {
                             }
                          }
                       }

如果您想StoragefileSystem使用以上任意一项

答案 1 :(得分:0)

我通过设置 httpLogs httpLoggingEnabled 属性来完成这项工作。

这是嵌套在站点资源中的配置资源:

  "resources": [
    {
      "apiVersion": "2018-02-01",
      "type": "config",
      "name": "logs",
      "dependsOn": [
        "[concat('Microsoft.Web/sites/', parameters('name'))]"
      ],
      "properties": {
        "applicationLogs": {
          "azureBlobStorage": {
            "level": "information",
            "retentionInDays": 15
          }
        },
        "httpLogs": {
          "fileSystem": {
            "retentioninMb": 35,
            "retentioninDays": 15,
            "enabled": true
          }
        },
        "requestTracingEnabled": true,
        "requestTracingExpirationTime": "9999-12-31T23:59:00Z",
        "remoteDebuggingEnabled": false,
        "httpLoggingEnabled": true,
        "logsDirectorySizeLimit": 34,
        "detailedErrorLoggingEnabled": true
      }
    }
  ]