Mission
After creating my web app. I want to see the logs in "Log Analytics Workspace" > "Logs".In order to so so, I need first to tell the "App Service Logs" to see my STDOUT and STDERR. This is quite easy in the UI; It is basically just turn the "Application Logging" toggle to "File System".
I want to this but not via UI but via Terraform scripts.
My Problem
Linux WebApp Documentation explains about whatlogs, application_logs and http_logs do but it does not explicitly say the relationship between them.
It turns out that
application_logs needs http_logs to work properly. I was passing ONLY application_logs and it did not have any effect on the toggle in the UI
Solution
Pass bothapplication_logs and http_logs, even if not interested in the http_logs it is required for application logs to work. Likely to be an implementation detail not well documented.
resource "azurerm_linux_web_app" "main" {
name = "${var.app_name}-web"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
service_plan_id = azurerm_service_plan.main.id
site_config {
...
}
app_settings = {
...
}
identity {
...
}
logs {
application_logs {
file_system_level = "Information" # Options: Off, Error, Warning, Information, Verbose
}
http_logs {
file_system {
retention_in_days = 7
retention_in_mb = 35
}
}
detailed_error_messages = true
failed_request_tracing = true
}
}
0 comments :
Post a Comment