Skip to content

Commit f84ec5a

Browse files
logging issue fix
1 parent 01f2fa2 commit f84ec5a

File tree

4 files changed

+73
-27
lines changed

4 files changed

+73
-27
lines changed

infra/main.bicep

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,18 +1270,6 @@ module avmAppConfig 'br/public:avm/res/app-configuration/configuration-store:0.9
12701270
name: 'APP_CPS_PROCESSES'
12711271
value: 'cps-processes'
12721272
}
1273-
{
1274-
name: 'APP_LOGGING_LEVEL'
1275-
value: 'INFO'
1276-
}
1277-
{
1278-
name: 'AZURE_PACKAGE_LOGGING_LEVEL'
1279-
value: 'WARNING'
1280-
}
1281-
{
1282-
name: 'AZURE_LOGGING_PACKAGES'
1283-
value: ''
1284-
}
12851273
{
12861274
name: 'APP_MESSAGE_QUEUE_EXTRACT'
12871275
value: 'content-pipeline-extract-queue'
@@ -1390,6 +1378,18 @@ module avmContainerApp_update 'br/public:avm/res/app/container-app:0.19.0' = {
13901378
name: 'APP_ENV'
13911379
value: 'prod'
13921380
}
1381+
{
1382+
name: 'APP_LOGGING_LEVEL'
1383+
value: 'INFO'
1384+
}
1385+
{
1386+
name: 'AZURE_PACKAGE_LOGGING_LEVEL'
1387+
value: 'WARNING'
1388+
}
1389+
{
1390+
name: 'AZURE_LOGGING_PACKAGES'
1391+
value: ''
1392+
}
13931393
]
13941394
}
13951395
]
@@ -1449,6 +1449,18 @@ module avmContainerApp_API_update 'br/public:avm/res/app/container-app:0.19.0' =
14491449
name: 'APP_ENV'
14501450
value: 'prod'
14511451
}
1452+
{
1453+
name: 'APP_LOGGING_LEVEL'
1454+
value: 'INFO'
1455+
}
1456+
{
1457+
name: 'AZURE_PACKAGE_LOGGING_LEVEL'
1458+
value: 'WARNING'
1459+
}
1460+
{
1461+
name: 'AZURE_LOGGING_PACKAGES'
1462+
value: ''
1463+
}
14521464
]
14531465
probes: [
14541466
// Liveness Probe - Checks if the app is still running

infra/main.json

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.37.4.10188",
9-
"templateHash": "17737076781026161010"
9+
"templateHash": "7117786631402623900"
1010
},
1111
"name": "Content Processing Solution Accelerator",
1212
"description": "Bicep template to deploy the Content Processing Solution Accelerator with AVM compliance."
@@ -35231,6 +35231,11 @@
3523135231
"principalId": "[reference('avmContainerApp').outputs.systemAssignedMIPrincipalId.value]",
3523235232
"roleDefinitionIdOrName": "Cognitive Services OpenAI User",
3523335233
"principalType": "ServicePrincipal"
35234+
},
35235+
{
35236+
"principalId": "[reference('avmContainerApp').outputs.systemAssignedMIPrincipalId.value]",
35237+
"roleDefinitionIdOrName": "Azure AI Developer",
35238+
"principalType": "ServicePrincipal"
3523435239
}
3523535240
]
3523635241
},
@@ -40908,8 +40913,8 @@
4090840913
"dependsOn": [
4090940914
"avmContainerApp",
4091040915
"avmManagedIdentity",
40911-
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
4091240916
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').contentUnderstanding)]",
40917+
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
4091340918
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
4091440919
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]",
4091540920
"logAnalyticsWorkspace",
@@ -55856,18 +55861,6 @@
5585655861
"name": "APP_CPS_PROCESSES",
5585755862
"value": "cps-processes"
5585855863
},
55859-
{
55860-
"name": "APP_LOGGING_LEVEL",
55861-
"value": "INFO"
55862-
},
55863-
{
55864-
"name": "AZURE_PACKAGE_LOGGING_LEVEL",
55865-
"value": "WARNING"
55866-
},
55867-
{
55868-
"name": "AZURE_LOGGING_PACKAGES",
55869-
"value": ""
55870-
},
5587155864
{
5587255865
"name": "APP_MESSAGE_QUEUE_EXTRACT",
5587355866
"value": "content-pipeline-extract-queue"
@@ -60404,6 +60397,18 @@
6040460397
{
6040560398
"name": "APP_ENV",
6040660399
"value": "prod"
60400+
},
60401+
{
60402+
"name": "APP_LOGGING_LEVEL",
60403+
"value": "INFO"
60404+
},
60405+
{
60406+
"name": "AZURE_PACKAGE_LOGGING_LEVEL",
60407+
"value": "WARNING"
60408+
},
60409+
{
60410+
"name": "AZURE_LOGGING_PACKAGES",
60411+
"value": ""
6040760412
}
6040860413
]
6040960414
}
@@ -62003,6 +62008,18 @@
6200362008
{
6200462009
"name": "APP_ENV",
6200562010
"value": "prod"
62011+
},
62012+
{
62013+
"name": "APP_LOGGING_LEVEL",
62014+
"value": "INFO"
62015+
},
62016+
{
62017+
"name": "AZURE_PACKAGE_LOGGING_LEVEL",
62018+
"value": "WARNING"
62019+
},
62020+
{
62021+
"name": "AZURE_LOGGING_PACKAGES",
62022+
"value": ""
6200662023
}
6200762024
],
6200862025
"probes": [

src/ContentProcessor/src/libs/base/application_main.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,22 @@ def __init__(self, env_file_path: str | None = None, **data):
4141
logging_level = getattr(
4242
logging, self.application_context.configuration.app_logging_level, logging.INFO
4343
)
44-
logging.basicConfig(level=logging_level)
44+
# Configure basic logging with format
45+
logging.basicConfig(
46+
level=logging_level,
47+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
48+
force=True # This ensures the configuration is applied
49+
)
50+
51+
package_level_str = self.application_context.configuration.azure_package_logging_level
52+
package_level = getattr(logging, package_level_str, logging.WARNING)
53+
packages = self.application_context.configuration.azure_logging_packages
54+
azure_logging_packages = packages.split(",") if packages else []
55+
56+
# Package config: Azure loggers set to WARNING to suppress INFO
57+
for logger_name in azure_logging_packages:
58+
logging.getLogger(logger_name).setLevel(package_level)
59+
logging.info(f"Logging configured - Basic: {self.application_context.configuration.app_logging_level}, Azure packages: {package_level_str}, Packages: {azure_logging_packages}")
4560

4661
def _load_env(self, env_file_path: str | None = None):
4762
# if .env file path is provided, load it

src/ContentProcessorAPI/app/appsettings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ class AppConfiguration(ModelBaseSettings):
5959
logging.basicConfig(
6060
level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL, logging.INFO),
6161
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
62+
force=True, # This ensures the configuration is applied
6263
)
6364

6465
# Package config: Azure loggers set to WARNING to suppress INFO
6566
for logger_name in AZURE_LOGGING_PACKAGES:
6667
logging.getLogger(logger_name).setLevel(
6768
getattr(logging, AZURE_PACKAGE_LOGGING_LEVEL, logging.WARNING)
6869
)
70+
logging.info(f"Logging configured - Basic: {AZURE_BASIC_LOGGING_LEVEL}, Azure packages: {AZURE_PACKAGE_LOGGING_LEVEL}, Packages: {AZURE_LOGGING_PACKAGES}")
6971

7072

7173
# Dependency Function

0 commit comments

Comments
 (0)