Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,9 @@ module webSite 'modules/web-sites.bicep' = {
UWSGI_THREADS:'2'
APP_ENV: 'prod'
AZURE_CLIENT_ID: userAssignedIdentity.outputs.clientId
// Logging Configuration
AZURE_BASIC_LOGGING_LEVEL: 'INFO'
AZURE_PACKAGE_LOGGING_LEVEL: 'WARNING'
}
// WAF aligned configuration for Monitoring
applicationInsightResourceId: enableMonitoring ? applicationInsights!.outputs.resourceId : null
Expand Down
6 changes: 4 additions & 2 deletions infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.37.4.10188",
"templateHash": "3418531138421621433"
"templateHash": "10419838746251975414"
}
},
"parameters": {
Expand Down Expand Up @@ -47243,7 +47243,9 @@
"UWSGI_PROCESSES": "2",
"UWSGI_THREADS": "2",
"APP_ENV": "prod",
"AZURE_CLIENT_ID": "[reference('userAssignedIdentity').outputs.clientId.value]"
"AZURE_CLIENT_ID": "[reference('userAssignedIdentity').outputs.clientId.value]",
"AZURE_BASIC_LOGGING_LEVEL": "INFO",
"AZURE_PACKAGE_LOGGING_LEVEL": "WARNING"
},
"applicationInsightResourceId": "[if(parameters('enableMonitoring'), reference('applicationInsights').outputs.resourceId.value, null())]"
}
Expand Down
8 changes: 7 additions & 1 deletion src/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ AZURE_COSMOSDB_MONGO_VCORE_CONTENT_COLUMNS=
AZURE_COSMOSDB_MONGO_VCORE_VECTOR_COLUMNS=
AI_STUDIO_DRAFT_FLOW_API_KEY=
AI_STUDIO_CHAT_FLOW_API_KEY=
AZURE_OPENAI_API_TYPE=
AZURE_OPENAI_API_TYPE=

# Logging Configuration
AZURE_BASIC_LOGGING_LEVEL=INFO
AZURE_PACKAGE_LOGGING_LEVEL=WARNING
# Optional: Comma-separated list of Azure packages to configure logging for
# AZURE_LOGGING_PACKAGES=azure.core.pipeline.policies.http_logging_policy,azure.identity.aio._internal,azure.monitor.opentelemetry.exporter.export._base
18 changes: 18 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ def assets(path):
if DEBUG_LOGGING:
logging.basicConfig(level=logging.DEBUG)

# Logging configuration from environment variables
AZURE_BASIC_LOGGING_LEVEL = os.environ.get("AZURE_BASIC_LOGGING_LEVEL", "INFO")
AZURE_PACKAGE_LOGGING_LEVEL = os.environ.get("AZURE_PACKAGE_LOGGING_LEVEL", "WARNING")
AZURE_LOGGING_PACKAGES = os.environ.get("AZURE_LOGGING_PACKAGES", "").split(",")
AZURE_LOGGING_PACKAGES = [pkg.strip() for pkg in AZURE_LOGGING_PACKAGES if pkg.strip()]

# Configure logging levels from environment variables
logging.basicConfig(
level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO)
)

# Configure Azure package logging levels only if packages are specified
azure_level = getattr(
logging, AZURE_PACKAGE_LOGGING_LEVEL.upper(), logging.WARNING
)
for logger_name in AZURE_LOGGING_PACKAGES:
logging.getLogger(logger_name).setLevel(azure_level)

# On Your Data Settings
DATASOURCE_TYPE = os.environ.get("DATASOURCE_TYPE", "AzureCognitiveSearch")
SEARCH_TOP_K = os.environ.get("SEARCH_TOP_K", 5)
Expand Down