diff --git a/infra/main.bicep b/infra/main.bicep index eeddf416..1acdaec7 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -1122,6 +1122,9 @@ module webSite 'modules/web-sites.bicep' = { AZURE_SEARCH_STRICTNESS: azureSearchStrictness AZURE_OPENAI_EMBEDDING_NAME: embeddingModel AZURE_OPENAI_EMBEDDING_ENDPOINT : aiFoundryAiServices.outputs.endpoint + AZURE_BASIC_LOGGING_LEVEL: 'INFO' + AZURE_PACKAGE_LOGGING_LEVEL: 'WARNING' + AZURE_LOGGING_PACKAGES: '' SQLDB_SERVER: sqlServerFqdn SQLDB_DATABASE: sqlDbName USE_INTERNAL_STREAM: useInternalStream diff --git a/infra/main.json b/infra/main.json index db7909f8..515dc388 100644 --- a/infra/main.json +++ b/infra/main.json @@ -6,7 +6,7 @@ "_generator": { "name": "bicep", "version": "0.37.4.10188", - "templateHash": "16197733130303817508" + "templateHash": "10200691163213391924" } }, "parameters": { @@ -29912,8 +29912,8 @@ } }, "dependsOn": [ - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]", + "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]", "logAnalyticsWorkspace", "userAssignedIdentity", "virtualNetwork" @@ -39522,8 +39522,8 @@ } }, "dependsOn": [ - "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]", "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]", + "[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]", "keyvault", "userAssignedIdentity", "virtualNetwork" @@ -49989,6 +49989,9 @@ "AZURE_SEARCH_STRICTNESS": "[variables('azureSearchStrictness')]", "AZURE_OPENAI_EMBEDDING_NAME": "[parameters('embeddingModel')]", "AZURE_OPENAI_EMBEDDING_ENDPOINT": "[reference('aiFoundryAiServices').outputs.endpoint.value]", + "AZURE_BASIC_LOGGING_LEVEL": "INFO", + "AZURE_PACKAGE_LOGGING_LEVEL": "WARNING", + "AZURE_LOGGING_PACKAGES": "", "SQLDB_SERVER": "[variables('sqlServerFqdn')]", "SQLDB_DATABASE": "[variables('sqlDbName')]", "USE_INTERNAL_STREAM": "[variables('useInternalStream')]", diff --git a/src/App/.env.sample b/src/App/.env.sample index 53ae69bf..3ad8478a 100644 --- a/src/App/.env.sample +++ b/src/App/.env.sample @@ -12,6 +12,11 @@ AZURE_OPENAI_ENDPOINT= AZURE_OPENAI_EMBEDDING_NAME="text-embedding-ada-002" AZURE_OPENAI_EMBEDDING_ENDPOINT= +# Logging settings +AZURE_BASIC_LOGGING_LEVEL="INFO" +AZURE_PACKAGE_LOGGING_LEVEL="WARNING" +# AZURE_LOGGING_PACKAGES="azure.core.pipeline.policies.http_logging_policy,azure.identity.aio._internal,azure.monitor.opentelemetry.exporter.export._base" + # User Interface UI_TITLE= UI_LOGO= diff --git a/src/App/app.py b/src/App/app.py index 0f154083..545f465b 100644 --- a/src/App/app.py +++ b/src/App/app.py @@ -56,18 +56,23 @@ ) # Configure logging -logging.basicConfig(level=logging.INFO) +basic_level = getattr( + logging, config.AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO +) +logging.basicConfig(level=basic_level) -# Suppress INFO logs from 'azure.core.pipeline.policies.http_logging_policy' -logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel( - logging.WARNING +# Configure Azure package logging levels +azure_packages_env = os.environ.get("AZURE_LOGGING_PACKAGES") +azure_packages = ( + [pkg.strip() for pkg in azure_packages_env.split(',')] + if azure_packages_env else [] ) -logging.getLogger("azure.identity.aio._internal").setLevel(logging.WARNING) -# Suppress info logs from OpenTelemetry exporter -logging.getLogger("azure.monitor.opentelemetry.exporter.export._base").setLevel( - logging.WARNING +package_level = getattr( + logging, config.AZURE_PACKAGE_LOGGING_LEVEL.upper(), logging.WARNING ) +for package in azure_packages: + logging.getLogger(package).setLevel(package_level) def create_app(): diff --git a/src/App/backend/common/config.py b/src/App/backend/common/config.py index 49775830..b3e33ae0 100644 --- a/src/App/backend/common/config.py +++ b/src/App/backend/common/config.py @@ -35,6 +35,14 @@ def __init__(self): "APPLICATIONINSIGHTS_CONNECTION_STRING" ) + # Azure Logging Configuration + self.AZURE_BASIC_LOGGING_LEVEL = os.environ.get( + "AZURE_BASIC_LOGGING_LEVEL", "INFO" + ) + self.AZURE_PACKAGE_LOGGING_LEVEL = os.environ.get( + "AZURE_PACKAGE_LOGGING_LEVEL", "WARNING" + ) + self.DEBUG = os.environ.get("DEBUG", "false") # Current minimum Azure OpenAI version supported