Skip to content

Commit f379729

Browse files
authored
Remove duplicate redacted/unredacted console logs (#42443)
1 parent 1f0e019 commit f379729

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@
3333
)
3434
if _console_logging_enabled:
3535
import sys
36-
36+
# Enable detailed console logs across Azure libraries
3737
azure_logger = logging.getLogger("azure")
3838
azure_logger.setLevel(logging.DEBUG)
3939
azure_logger.addHandler(logging.StreamHandler(stream=sys.stdout))
40+
# Exclude detailed logs for network calls associated with getting Entra ID token.
4041
identity_logger = logging.getLogger("azure.identity")
4142
identity_logger.setLevel(logging.ERROR)
43+
# Make sure regular (redacted) detailed azure.core logs are not shown, as we are about to
44+
# turn on non-redacted logs by passing 'logging_enable=True' to the client constructor
45+
# (which are implemented as a separate logging policy)
46+
logger = logging.getLogger("azure.core.pipeline.policies.http_logging_policy")
47+
logger.setLevel(logging.ERROR)
4248

4349

4450
def _patch_user_agent(user_agent: Optional[str]) -> str:

sdk/ai/azure-ai-projects/azure/ai/projects/aio/_patch.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@
3434
)
3535
if _console_logging_enabled:
3636
import sys
37-
37+
# Enable detailed console logs across Azure libraries
3838
azure_logger = logging.getLogger("azure")
3939
azure_logger.setLevel(logging.DEBUG)
4040
azure_logger.addHandler(logging.StreamHandler(stream=sys.stdout))
41+
# Exclude detailed logs for network calls associated with getting Entra ID token.
4142
identity_logger = logging.getLogger("azure.identity")
4243
identity_logger.setLevel(logging.ERROR)
44+
# Make sure regular (redacted) detailed azure.core logs are not shown, as we are about to
45+
# turn on non-redacted logs by passing 'logging_enable=True' to the client constructor
46+
# (which are implemented as a separate logging policy)
47+
logger = logging.getLogger("azure.core.pipeline.policies.http_logging_policy")
48+
logger.setLevel(logging.ERROR)
4349

4450

4551
class AIProjectClient(AIProjectClientGenerated): # pylint: disable=too-many-instance-attributes

0 commit comments

Comments
 (0)