Skip to content

Conversation

@Nikhil172913832
Copy link
Contributor

Resolves #43955

Changes

  • Add logging_level parameter to HttpLoggingPolicy.__init__ with default logging.INFO
  • Replace hardcoded logging.INFO checks and logger.info() calls with configurable level
  • Add tests for custom log level in both sync and async test suites
  • Maintain backward compatibility with default INFO level

This change allows users to configure the logging level when creating HttpLoggingPolicy, addressing the need for flexibility in centralized logging systems (e.g., Grafana/Loki) where users may prefer DEBUG or other log levels instead of the hardcoded INFO level.

Usage:

# Default behavior (INFO level) - backward compatible
policy = HttpLoggingPolicy()

# Custom DEBUG level
policy = HttpLoggingPolicy(logging_level=logging.DEBUG)

# Custom WARNING level
policy = HttpLoggingPolicy(logging_level=logging.WARNING)

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

- Add logging_level parameter to HttpLoggingPolicy.__init__ with default logging.INFO
- Replace hardcoded logging.INFO checks and logger.info() calls with configurable level
- Add tests for custom log level in both sync and async test suites
- Maintain backward compatibility with default INFO level
Copilot AI review requested due to automatic review settings November 20, 2025 10:02
@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Nov 20, 2025
@github-actions
Copy link

Thank you for your contribution @Nikhil172913832! We will review the pull request and get back to you soon.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes the HttpLoggingPolicy log level configurable by adding a logging_level parameter to the constructor. This allows users to control the log level (e.g., DEBUG, WARNING) instead of being restricted to the hardcoded INFO level, addressing needs for flexibility in centralized logging systems.

Key Changes:

  • Added logging_level parameter to HttpLoggingPolicy.__init__ with a default value of logging.INFO
  • Updated all logging calls throughout the policy to use the configurable level
  • Added test coverage in both sync and async test suites to verify custom log level functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
sdk/core/azure-core/azure/core/pipeline/policies/_universal.py Added logging_level parameter to constructor and replaced all hardcoded logging.INFO references with the configurable level
sdk/core/azure-core/tests/test_http_logging_policy.py Added test to verify HttpLoggingPolicy respects custom DEBUG log level
sdk/core/azure-core/tests/async_tests/test_http_logging_policy_async.py Added async test to verify HttpLoggingPolicy respects custom DEBUG log level

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-core

Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Overall, the implementation looks good. Since an end user would be passing this kwarg through their SDK clients (e.g. BlobServiceClient, etc.), I wonder if we should make this a bit more specific like http_logging_level.

Would like to get others' opinions on this addition and naming. cc @annatisch @kashifkhan @johanste

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make HttpLoggingPolicy log level configurable

2 participants