Skip to content

Commit 61bb88f

Browse files
CopilotlmazuelCopilot
authored
Add logging section to azure-core README.md (#42391)
* Initial plan * Add logging section to azure-core README.md Co-authored-by: lmazuel <[email protected]> * Update sdk/core/azure-core/README.md Co-authored-by: Copilot <[email protected]> * Update sdk/core/azure-core/README.md Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: lmazuel <[email protected]> Co-authored-by: Laurent Mazuel <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent f58ae82 commit 61bb88f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

sdk/core/azure-core/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,33 @@ foo = Foo(
229229
)
230230
```
231231

232+
## Logging
233+
234+
Azure libraries follow the guidance of Python's standard [logging](https://docs.python.org/3/library/logging.html) module. By following the Python documentation on logging, you should be able to configure logging for Azure libraries effectively.
235+
236+
Azure library loggers use a dot-based separated syntax, where the first section is always `azure`, followed by the package name. For example, the Azure Core library uses logger names that start with `azure.core`.
237+
238+
Here's an example of how to configure logging for Azure libraries:
239+
240+
```python
241+
import logging
242+
import sys
243+
244+
# Enable detailed console logs across Azure libraries
245+
azure_logger = logging.getLogger("azure")
246+
azure_logger.setLevel(logging.DEBUG)
247+
azure_logger.addHandler(logging.StreamHandler(stream=sys.stdout))
248+
249+
# Exclude detailed logs for network calls associated with getting Entra ID token.
250+
identity_logger = logging.getLogger("azure.identity")
251+
identity_logger.setLevel(logging.ERROR)
252+
253+
# Make sure regular (redacted) detailed azure.core logs are not shown, as we are about to
254+
# turn on non-redacted logs by passing 'logging_enable=True' to the client constructor
255+
logger = logging.getLogger("azure.core.pipeline.policies.http_logging_policy")
256+
logger.setLevel(logging.ERROR)
257+
```
258+
232259
## Contributing
233260

234261
This project welcomes contributions and suggestions. Most contributions require

0 commit comments

Comments
 (0)