From f84ec5aed2e23cb0691f0e5b5e8d47f9878ec489 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 4 Dec 2025 17:50:14 +0530 Subject: [PATCH 1/5] logging issue fix --- infra/main.bicep | 36 ++++++++++----- infra/main.json | 45 +++++++++++++------ .../src/libs/base/application_main.py | 17 ++++++- src/ContentProcessorAPI/app/appsettings.py | 2 + 4 files changed, 73 insertions(+), 27 deletions(-) diff --git a/infra/main.bicep b/infra/main.bicep index 71a653c2..9e7aec8e 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -1270,18 +1270,6 @@ module avmAppConfig 'br/public:avm/res/app-configuration/configuration-store:0.9 name: 'APP_CPS_PROCESSES' value: 'cps-processes' } - { - name: 'APP_LOGGING_LEVEL' - value: 'INFO' - } - { - name: 'AZURE_PACKAGE_LOGGING_LEVEL' - value: 'WARNING' - } - { - name: 'AZURE_LOGGING_PACKAGES' - value: '' - } { name: 'APP_MESSAGE_QUEUE_EXTRACT' value: 'content-pipeline-extract-queue' @@ -1390,6 +1378,18 @@ module avmContainerApp_update 'br/public:avm/res/app/container-app:0.19.0' = { name: 'APP_ENV' value: 'prod' } + { + name: 'APP_LOGGING_LEVEL' + value: 'INFO' + } + { + name: 'AZURE_PACKAGE_LOGGING_LEVEL' + value: 'WARNING' + } + { + name: 'AZURE_LOGGING_PACKAGES' + value: '' + } ] } ] @@ -1449,6 +1449,18 @@ module avmContainerApp_API_update 'br/public:avm/res/app/container-app:0.19.0' = name: 'APP_ENV' value: 'prod' } + { + name: 'APP_LOGGING_LEVEL' + value: 'INFO' + } + { + name: 'AZURE_PACKAGE_LOGGING_LEVEL' + value: 'WARNING' + } + { + name: 'AZURE_LOGGING_PACKAGES' + value: '' + } ] probes: [ // Liveness Probe - Checks if the app is still running diff --git a/infra/main.json b/infra/main.json index 70291159..aa72c147 100644 --- a/infra/main.json +++ b/infra/main.json @@ -6,7 +6,7 @@ "_generator": { "name": "bicep", "version": "0.37.4.10188", - "templateHash": "17737076781026161010" + "templateHash": "7117786631402623900" }, "name": "Content Processing Solution Accelerator", "description": "Bicep template to deploy the Content Processing Solution Accelerator with AVM compliance." @@ -35231,6 +35231,11 @@ "principalId": "[reference('avmContainerApp').outputs.systemAssignedMIPrincipalId.value]", "roleDefinitionIdOrName": "Cognitive Services OpenAI User", "principalType": "ServicePrincipal" + }, + { + "principalId": "[reference('avmContainerApp').outputs.systemAssignedMIPrincipalId.value]", + "roleDefinitionIdOrName": "Azure AI Developer", + "principalType": "ServicePrincipal" } ] }, @@ -40908,8 +40913,8 @@ "dependsOn": [ "avmContainerApp", "avmManagedIdentity", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').contentUnderstanding)]", + "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]", "logAnalyticsWorkspace", @@ -55856,18 +55861,6 @@ "name": "APP_CPS_PROCESSES", "value": "cps-processes" }, - { - "name": "APP_LOGGING_LEVEL", - "value": "INFO" - }, - { - "name": "AZURE_PACKAGE_LOGGING_LEVEL", - "value": "WARNING" - }, - { - "name": "AZURE_LOGGING_PACKAGES", - "value": "" - }, { "name": "APP_MESSAGE_QUEUE_EXTRACT", "value": "content-pipeline-extract-queue" @@ -60404,6 +60397,18 @@ { "name": "APP_ENV", "value": "prod" + }, + { + "name": "APP_LOGGING_LEVEL", + "value": "INFO" + }, + { + "name": "AZURE_PACKAGE_LOGGING_LEVEL", + "value": "WARNING" + }, + { + "name": "AZURE_LOGGING_PACKAGES", + "value": "" } ] } @@ -62003,6 +62008,18 @@ { "name": "APP_ENV", "value": "prod" + }, + { + "name": "APP_LOGGING_LEVEL", + "value": "INFO" + }, + { + "name": "AZURE_PACKAGE_LOGGING_LEVEL", + "value": "WARNING" + }, + { + "name": "AZURE_LOGGING_PACKAGES", + "value": "" } ], "probes": [ diff --git a/src/ContentProcessor/src/libs/base/application_main.py b/src/ContentProcessor/src/libs/base/application_main.py index 453f228d..864f3410 100644 --- a/src/ContentProcessor/src/libs/base/application_main.py +++ b/src/ContentProcessor/src/libs/base/application_main.py @@ -41,7 +41,22 @@ def __init__(self, env_file_path: str | None = None, **data): logging_level = getattr( logging, self.application_context.configuration.app_logging_level, logging.INFO ) - logging.basicConfig(level=logging_level) + # Configure basic logging with format + logging.basicConfig( + level=logging_level, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + force=True # This ensures the configuration is applied + ) + + package_level_str = self.application_context.configuration.azure_package_logging_level + package_level = getattr(logging, package_level_str, logging.WARNING) + packages = self.application_context.configuration.azure_logging_packages + azure_logging_packages = packages.split(",") if packages else [] + + # Package config: Azure loggers set to WARNING to suppress INFO + for logger_name in azure_logging_packages: + logging.getLogger(logger_name).setLevel(package_level) + logging.info(f"Logging configured - Basic: {self.application_context.configuration.app_logging_level}, Azure packages: {package_level_str}, Packages: {azure_logging_packages}") def _load_env(self, env_file_path: str | None = None): # if .env file path is provided, load it diff --git a/src/ContentProcessorAPI/app/appsettings.py b/src/ContentProcessorAPI/app/appsettings.py index c4aeeeb0..228be4f0 100644 --- a/src/ContentProcessorAPI/app/appsettings.py +++ b/src/ContentProcessorAPI/app/appsettings.py @@ -59,6 +59,7 @@ class AppConfiguration(ModelBaseSettings): logging.basicConfig( level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL, logging.INFO), format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", + force=True, # This ensures the configuration is applied ) # Package config: Azure loggers set to WARNING to suppress INFO @@ -66,6 +67,7 @@ class AppConfiguration(ModelBaseSettings): logging.getLogger(logger_name).setLevel( getattr(logging, AZURE_PACKAGE_LOGGING_LEVEL, logging.WARNING) ) +logging.info(f"Logging configured - Basic: {AZURE_BASIC_LOGGING_LEVEL}, Azure packages: {AZURE_PACKAGE_LOGGING_LEVEL}, Packages: {AZURE_LOGGING_PACKAGES}") # Dependency Function From 8f5f6cb25309055dfc8b24dfda3f1338d7f7ab34 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 4 Dec 2025 17:57:11 +0530 Subject: [PATCH 2/5] lint issue fix --- src/ContentProcessor/src/libs/base/application_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ContentProcessor/src/libs/base/application_main.py b/src/ContentProcessor/src/libs/base/application_main.py index 864f3410..d9a3f44c 100644 --- a/src/ContentProcessor/src/libs/base/application_main.py +++ b/src/ContentProcessor/src/libs/base/application_main.py @@ -47,7 +47,7 @@ def __init__(self, env_file_path: str | None = None, **data): format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', force=True # This ensures the configuration is applied ) - + package_level_str = self.application_context.configuration.azure_package_logging_level package_level = getattr(logging, package_level_str, logging.WARNING) packages = self.application_context.configuration.azure_logging_packages From 66b5bd6d4b53e4868f65cbe190c873868dea004e Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 4 Dec 2025 17:59:55 +0530 Subject: [PATCH 3/5] updated bicep --- infra/main.bicep | 24 ++++++++++++++++++++++++ infra/main.json | 30 +++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/infra/main.bicep b/infra/main.bicep index 9e7aec8e..df4f1adb 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -934,6 +934,18 @@ module avmContainerApp 'br/public:avm/res/app/container-app:0.19.0' = { name: 'APP_ENV' value: 'prod' } + { + name: 'APP_LOGGING_LEVEL' + value: 'INFO' + } + { + name: 'AZURE_PACKAGE_LOGGING_LEVEL' + value: 'WARNING' + } + { + name: 'AZURE_LOGGING_PACKAGES' + value: '' + } ] } ] @@ -982,6 +994,18 @@ module avmContainerApp_API 'br/public:avm/res/app/container-app:0.19.0' = { name: 'APP_ENV' value: 'prod' } + { + name: 'APP_LOGGING_LEVEL' + value: 'INFO' + } + { + name: 'AZURE_PACKAGE_LOGGING_LEVEL' + value: 'WARNING' + } + { + name: 'AZURE_LOGGING_PACKAGES' + value: '' + } ] probes: [ // Liveness Probe - Checks if the app is still running diff --git a/infra/main.json b/infra/main.json index aa72c147..19c31913 100644 --- a/infra/main.json +++ b/infra/main.json @@ -6,7 +6,7 @@ "_generator": { "name": "bicep", "version": "0.37.4.10188", - "templateHash": "7117786631402623900" + "templateHash": "11428630106677040832" }, "name": "Content Processing Solution Accelerator", "description": "Bicep template to deploy the Content Processing Solution Accelerator with AVM compliance." @@ -40913,10 +40913,10 @@ "dependsOn": [ "avmContainerApp", "avmManagedIdentity", + "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').contentUnderstanding)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]", "logAnalyticsWorkspace", "virtualNetwork" ] @@ -43518,8 +43518,8 @@ "dependsOn": [ "avmContainerApp", "avmManagedIdentity", - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').contentUnderstanding)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]", + "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').contentUnderstanding)]", "virtualNetwork" ] }, @@ -45004,6 +45004,18 @@ { "name": "APP_ENV", "value": "prod" + }, + { + "name": "APP_LOGGING_LEVEL", + "value": "INFO" + }, + { + "name": "AZURE_PACKAGE_LOGGING_LEVEL", + "value": "WARNING" + }, + { + "name": "AZURE_LOGGING_PACKAGES", + "value": "" } ] } @@ -46604,6 +46616,18 @@ { "name": "APP_ENV", "value": "prod" + }, + { + "name": "APP_LOGGING_LEVEL", + "value": "INFO" + }, + { + "name": "AZURE_PACKAGE_LOGGING_LEVEL", + "value": "WARNING" + }, + { + "name": "AZURE_LOGGING_PACKAGES", + "value": "" } ], "probes": [ From b13466080f7c459fc26c4ef3fea7a83628658fc0 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Fri, 5 Dec 2025 17:01:32 +0530 Subject: [PATCH 4/5] reverted code changes --- .../src/libs/base/application_main.py | 19 ++----------------- src/ContentProcessorAPI/app/appsettings.py | 4 +--- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/ContentProcessor/src/libs/base/application_main.py b/src/ContentProcessor/src/libs/base/application_main.py index d9a3f44c..943f550c 100644 --- a/src/ContentProcessor/src/libs/base/application_main.py +++ b/src/ContentProcessor/src/libs/base/application_main.py @@ -41,22 +41,7 @@ def __init__(self, env_file_path: str | None = None, **data): logging_level = getattr( logging, self.application_context.configuration.app_logging_level, logging.INFO ) - # Configure basic logging with format - logging.basicConfig( - level=logging_level, - format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', - force=True # This ensures the configuration is applied - ) - - package_level_str = self.application_context.configuration.azure_package_logging_level - package_level = getattr(logging, package_level_str, logging.WARNING) - packages = self.application_context.configuration.azure_logging_packages - azure_logging_packages = packages.split(",") if packages else [] - - # Package config: Azure loggers set to WARNING to suppress INFO - for logger_name in azure_logging_packages: - logging.getLogger(logger_name).setLevel(package_level) - logging.info(f"Logging configured - Basic: {self.application_context.configuration.app_logging_level}, Azure packages: {package_level_str}, Packages: {azure_logging_packages}") + logging.basicConfig(level=logging_level) def _load_env(self, env_file_path: str | None = None): # if .env file path is provided, load it @@ -72,4 +57,4 @@ def _load_env(self, env_file_path: str | None = None): return env_file_path def _get_derived_class_location(self): - return inspect.getfile(self.__class__) + return inspect.getfile(self.__class__) \ No newline at end of file diff --git a/src/ContentProcessorAPI/app/appsettings.py b/src/ContentProcessorAPI/app/appsettings.py index 228be4f0..00eb370b 100644 --- a/src/ContentProcessorAPI/app/appsettings.py +++ b/src/ContentProcessorAPI/app/appsettings.py @@ -59,7 +59,6 @@ class AppConfiguration(ModelBaseSettings): logging.basicConfig( level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL, logging.INFO), format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", - force=True, # This ensures the configuration is applied ) # Package config: Azure loggers set to WARNING to suppress INFO @@ -67,9 +66,8 @@ class AppConfiguration(ModelBaseSettings): logging.getLogger(logger_name).setLevel( getattr(logging, AZURE_PACKAGE_LOGGING_LEVEL, logging.WARNING) ) -logging.info(f"Logging configured - Basic: {AZURE_BASIC_LOGGING_LEVEL}, Azure packages: {AZURE_PACKAGE_LOGGING_LEVEL}, Packages: {AZURE_LOGGING_PACKAGES}") # Dependency Function def get_app_config() -> AppConfiguration: - return app_config + return app_config \ No newline at end of file From 96349e273b81ef83bf3e7f347173ee481733d747 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Fri, 5 Dec 2025 17:02:50 +0530 Subject: [PATCH 5/5] lint issue fix --- src/ContentProcessor/src/libs/base/application_main.py | 2 +- src/ContentProcessorAPI/app/appsettings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ContentProcessor/src/libs/base/application_main.py b/src/ContentProcessor/src/libs/base/application_main.py index 943f550c..453f228d 100644 --- a/src/ContentProcessor/src/libs/base/application_main.py +++ b/src/ContentProcessor/src/libs/base/application_main.py @@ -57,4 +57,4 @@ def _load_env(self, env_file_path: str | None = None): return env_file_path def _get_derived_class_location(self): - return inspect.getfile(self.__class__) \ No newline at end of file + return inspect.getfile(self.__class__) diff --git a/src/ContentProcessorAPI/app/appsettings.py b/src/ContentProcessorAPI/app/appsettings.py index 00eb370b..c4aeeeb0 100644 --- a/src/ContentProcessorAPI/app/appsettings.py +++ b/src/ContentProcessorAPI/app/appsettings.py @@ -70,4 +70,4 @@ class AppConfiguration(ModelBaseSettings): # Dependency Function def get_app_config() -> AppConfiguration: - return app_config \ No newline at end of file + return app_config