@@ -59,7 +59,7 @@ def __init__(self, env_file_path: str | None = None, **data):
5959 1. Load ``.env`` from *env_file_path* (or derive from subclass location).
6060 2. Read Azure App Configuration and inject values into ``os.environ``.
6161 3. Populate ``application_context`` with config and Azure credentials.
62- 4. Configure Python logging if enabled in config .
62+ 4. Configure Python logging unconditionally .
6363 5. Call ``self.initialize()``.
6464
6565 Args:
@@ -80,28 +80,39 @@ def __init__(self, env_file_path: str | None = None, **data):
8080
8181 self .application_context .set_configuration (AppConfiguration ())
8282
83- if self .application_context .configuration .app_logging_enable :
84- logging_level = getattr (
85- logging , self .application_context .configuration .app_logging_level
83+ # Configure logging unconditionally
84+ logging_level = getattr (
85+ logging ,
86+ self .application_context .configuration .app_logging_level ,
87+ logging .INFO ,
88+ )
89+ logging .basicConfig (
90+ level = logging_level ,
91+ format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" ,
92+ )
93+
94+ # Suppress noisy Azure SDK and OpenTelemetry internal loggers
95+ logging .getLogger ("azure.core.pipeline.policies.http_logging_policy" ).setLevel (logging .WARNING )
96+ logging .getLogger ("azure.core.pipeline.policies._universal" ).setLevel (logging .WARNING )
97+ logging .getLogger ("opentelemetry.sdk" ).setLevel (logging .WARNING )
98+ logging .getLogger ("azure.monitor.opentelemetry.exporter.export._base" ).setLevel (logging .WARNING )
99+
100+ if self .application_context .configuration .azure_logging_packages :
101+ azure_level = getattr (
102+ logging ,
103+ self .application_context .configuration .azure_package_logging_level .upper (),
104+ logging .WARNING ,
86105 )
87- logging .basicConfig (level = logging_level )
88-
89- if self .application_context .configuration .azure_logging_packages :
90- azure_level = getattr (
91- logging ,
92- self .application_context .configuration .azure_package_logging_level .upper (),
93- logging .WARNING ,
94- )
95- for logger_name in filter (
96- None ,
97- (
98- pkg .strip ()
99- for pkg in self .application_context .configuration .azure_logging_packages .split (
100- ","
101- )
102- ),
103- ):
104- logging .getLogger (logger_name ).setLevel (azure_level )
106+ for logger_name in filter (
107+ None ,
108+ (
109+ pkg .strip ()
110+ for pkg in self .application_context .configuration .azure_logging_packages .split (
111+ ","
112+ )
113+ ),
114+ ):
115+ logging .getLogger (logger_name ).setLevel (azure_level )
105116
106117 self .initialize ()
107118
0 commit comments