Skip to content

Support logging level config of handler through configure_azure_monitor #36395

Open
@yli02

Description

@yli02

Is your feature request related to a problem? Please describe.
The current logging configuration in [1] does not support to set the logging level for handler in [2], and this prevents to separate the logging to Azure and local in different levels based on logger hierarchy. For example

import logging
from azure.monitor.opentelemetry import configure_azure_monitor

app_logger = logging.getLogger("App")
app_logger.setLevel(logging.ERROR)

app_local_logger = logging.getLogger("App.local")
app_local_logger.setLevel(logging.INFO)

configure_azure_monitor(connection_string="", logger_name="app_logger")

In the application, we would like to always use logger "app_logger_local" for different level of loggings to stdout and stderr, and relying on logging hierarchy to pass logs to "app_logger". And we only would like to use Azure AppInsights to collect log with level ERROR or higher.

But this design is so far not feasible, as there is no checking of parent logger level at [3], see also [4].

Describe the solution you'd like
It would be great if a new argument could be added to [1], like logging_level to setup the logging level of the handler in [2], so we could rely on the above example code to collect loggings in different levels at different destination.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
[1]

def configure_azure_monitor(**kwargs) -> None: # pylint: disable=C4758

[2]

handler = LoggingHandler(logger_provider=logger_provider)

[3] https://github.com/python/cpython/blob/15d48aea02099ffc5bdc5511cc53ced460cb31b9/Lib/logging/__init__.py#L1715

[4] python/cpython#75045 (comment)

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Monitor - DistroMonitor OpenTelemetry DistroService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-requestThis issue requires a new behavior in the product in order be resolved.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions