File tree Expand file tree Collapse file tree 5 files changed +31
-17
lines changed
Expand file tree Collapse file tree 5 files changed +31
-17
lines changed Original file line number Diff line number Diff line change @@ -1500,6 +1500,9 @@ module webSite 'modules/web-sites.bicep' = {
15001500 WEBSITES_CONTAINER_START_TIME_LIMIT : '1800' // 30 minutes, adjust as needed
15011501 BACKEND_API_URL : 'https://${containerApp .outputs .fqdn }'
15021502 AUTH_ENABLED : 'false'
1503+ AZURE_BASIC_LOGGING_LEVEL : 'INFO'
1504+ AZURE_PACKAGE_LOGGING_LEVEL : 'WARNING'
1505+ AZURE_LOGGING_PACKAGES : ''
15031506 }
15041507 // WAF aligned configuration for Monitoring
15051508 applicationInsightResourceId : enableMonitoring ? applicationInsights !.outputs .resourceId : null
Original file line number Diff line number Diff line change @@ -1856,6 +1856,9 @@ module webSite 'modules/web-sites.bicep' = {
18561856 //WEBSITES_CONTAINER_START_TIME_LIMIT: '1800' // 30 minutes, adjust as needed
18571857 BACKEND_API_URL : 'https://${containerApp .outputs .fqdn }'
18581858 AUTH_ENABLED : 'false'
1859+ AZURE_BASIC_LOGGING_LEVEL : 'INFO'
1860+ AZURE_PACKAGE_LOGGING_LEVEL : 'WARNING'
1861+ AZURE_LOGGING_PACKAGES : ''
18591862 ENABLE_ORYX_BUILD : 'True'
18601863 }
18611864 // WAF aligned configuration for Monitoring
Original file line number Diff line number Diff line change @@ -33,3 +33,11 @@ AZURE_AI_SEARCH_INDEX_NAME=
3333AZURE_AI_SEARCH_ENDPOINT =
3434AZURE_AI_SEARCH_API_KEY =
3535BING_CONNECTION_NAME =
36+
37+ # Basic application logging (default: INFO level)
38+ AZURE_BASIC_LOGGING_LEVEL = INFO
39+ # Azure package logging (default: WARNING level to suppress INFO)
40+ AZURE_PACKAGE_LOGGING_LEVEL = WARNING
41+ # Comma-separated list of specific logger names to configure (default: empty - no custom loggers)
42+ # Example: AZURE_LOGGING_PACKAGES=azure.identity.aio._internal,azure.monitor.opentelemetry.exporter.export._base
43+ AZURE_LOGGING_PACKAGES =
Original file line number Diff line number Diff line change @@ -60,23 +60,18 @@ async def lifespan(app: FastAPI):
6060 "No Application Insights Instrumentation Key found. Skipping configuration"
6161 )
6262
63- # Configure logging
64- logging .basicConfig (level = logging .INFO )
65-
66- # Suppress INFO logs from 'azure.core.pipeline.policies.http_logging_policy'
67- logging .getLogger ("azure.core.pipeline.policies.http_logging_policy" ).setLevel (
68- logging .WARNING
69- )
70- logging .getLogger ("azure.identity.aio._internal" ).setLevel (logging .WARNING )
71-
72- # # Suppress info logs from OpenTelemetry exporter
73- logging .getLogger ("azure.monitor.opentelemetry.exporter.export._base" ).setLevel (
74- logging .WARNING
75- )
76-
77- logging .getLogger ("opentelemetry.sdk" ).setLevel (
78- logging .ERROR
79- )
63+ # Configure logging levels from environment variables
64+ logging .basicConfig (level = getattr (logging , config .AZURE_BASIC_LOGGING_LEVEL .upper (), logging .INFO ))
65+
66+ # Configure Azure package logging levels
67+ azure_level = getattr (logging , config .AZURE_PACKAGE_LOGGING_LEVEL .upper (), logging .WARNING )
68+ # Parse comma-separated logging packages
69+ if config .AZURE_LOGGING_PACKAGES :
70+ packages = [pkg .strip () for pkg in config .AZURE_LOGGING_PACKAGES .split ("," ) if pkg .strip ()]
71+ for logger_name in packages :
72+ logging .getLogger (logger_name ).setLevel (azure_level )
73+
74+ logging .getLogger ("opentelemetry.sdk" ).setLevel (logging .ERROR )
8075
8176# Initialize the FastAPI app
8277app = FastAPI (lifespan = lifespan )
Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ def __init__(self):
7373 # Azure Search settings
7474 self .AZURE_SEARCH_ENDPOINT = self ._get_optional ("AZURE_AI_SEARCH_ENDPOINT" )
7575
76+ # Logging settings
77+ self .AZURE_BASIC_LOGGING_LEVEL = self ._get_optional ("AZURE_BASIC_LOGGING_LEVEL" , "INFO" )
78+ self .AZURE_PACKAGE_LOGGING_LEVEL = self ._get_optional ("AZURE_PACKAGE_LOGGING_LEVEL" , "WARNING" )
79+ self .AZURE_LOGGING_PACKAGES = self ._get_optional ("AZURE_LOGGING_PACKAGES" )
80+
7681 # Optional MCP server endpoint (for local MCP server or remote)
7782 # Example: http://127.0.0.1:8000/mcp
7883 self .MCP_SERVER_ENDPOINT = self ._get_optional ("MCP_SERVER_ENDPOINT" )
You can’t perform that action at this time.
0 commit comments