Http Logging/Tracing

Hi, does anyone know of a way to log/trace http request/response messages sent and received by the python sdk for generate content operations?

2 Likes
import logging

# Configure logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging. DEBUG)
DEBUG)

Just consider adding these lines before making your API calls and you’ll see detailed HTTP traffic in your console output

1 Like

I’m looking for the same answer but using the node front end. I would think that this would be a common request! (pardon the pun)

I’m not sure if it’s quite what you’re looking for, but I just realized that you can use Chrome devtools Network tracing to see/inspect the raw requests in an individual session. That was enough for my use case, though obviously it is not a true logging solution.

HTTP was designed to be easily traceable. A language independent solution can be put together using a proxy HTTP server. Say you want to trace the http traffic to https://generativelanguage.googleapis.com/ from your LLM app running on your mobile device. Set up, using any old PC you have, an Apache web server as http proxy between your WiFi and internet. Any http request from your mobile device will go through the http proxy and your Apache will log whatever fields you wish to examine. All responses from the Google backend will similarly go through the proxy and you can log whichever fields you wish as well.

Hope that helps.