Theom
08/21/2025, 12:16 PMMarvin
08/21/2025, 12:16 PMMarvin
08/21/2025, 12:24 PM.serve()
process): the HTTP calls your process makes to the Prefect API
2) Server-side (the Prefect API service itself)
Here’s how to get both.
Client-side HTTP logs (see the communication your flow makes)
- Set Prefect to DEBUG and include HTTP libraries as extra loggers so their output is routed through Prefect’s handlers:
export PREFECT_LOGGING_LEVEL=DEBUG
export PREFECT_LOGGING_EXTRA_LOGGERS=httpx,httpcore,prefect.client
python your_flow_script.py
- You’ll see request/response details from httpx/httpcore
in your console and in Prefect logs (since Prefect forwards logs to the API). This is the easiest way to “see the communication” when using .serve()
.
- You can do it programmatically too:
import os
os.environ["PREFECT_LOGGING_LEVEL"] = "DEBUG"
os.environ["PREFECT_LOGGING_EXTRA_LOGGERS"] = "httpx,httpcore,prefect.client"
from prefect import flow
@flow
def my_flow():
...
if __name__ == "__main__":
my_flow.serve(name="my-deployment")
- More on customizing Prefect logging: Logging customization (Prefect 3)
Server-side logs
- Prefect Cloud: server logs are not exposed. You can still use the client-side approach above. If you need a record of actions, Cloud Pro/Enterprise has Audit Logs: Audit logs (Cloud)
- Self-hosted Prefect Server:
- If you start it with the CLI, you can increase server log verbosity:
prefect server start --log-level DEBUG
You’ll see API logs in that terminal. The --log-level
maps to PREFECT_SERVER_LOGGING_LEVEL
.
- If you run it in Docker, tail the API container logs:
docker ps # find your Prefect API container (often “prefect-server”, “prefect-api”, or from your compose/helm name)
docker logs -f <container_name>
- Kubernetes:
kubectl get pods -n <namespace>
kubectl logs -f <prefect-api-pod> -n <namespace>
A couple of tips
- Prefer httpx,httpcore
in PREFECT_LOGGING_EXTRA_LOGGERS
for very detailed HTTP-level output.
- Including prefect.client
can be useful for higher-level client messages.
- Sensitive data (like API keys) will be obfuscated by Prefect’s logging filters.
Would you share whether you’re using Prefect Cloud or a self-hosted Server, and how you’re running the server (CLI, Docker, Kubernetes)? I can tailor exact commands for your setup.Theom
08/21/2025, 12:30 PMMarvin
08/21/2025, 1:26 PMMarvin
08/21/2025, 1:29 PMhttpx/httpcore
is the quickest way to see the API chatter from .serve()
.
Since you’re self-hosting Prefect Server in Podman, here are a couple of tips in case you ever want the server-side logs too:
- Tail server logs (Podman):
podman ps # find your Prefect API container
podman logs -f <container_name>
- Run the server with DEBUG logging (either via CLI flags or env var)
- If you launch the container with prefect server start
as the entrypoint:
podman run ... prefect server start --log-level DEBUG
- Or with an env var:
podman run -e PREFECT_SERVER_LOGGING_LEVEL=DEBUG ...
Note: changing the log level requires restarting the container.
And for the client-side logging you’re planning to use, this is usually all you need:
export PREFECT_LOGGING_LEVEL=DEBUG
export PREFECT_LOGGING_EXTRA_LOGGERS=httpx,httpcore,prefect.client
python your_flow_script.py
Be aware that httpx/httpcore
at DEBUG is quite verbose (headers, connection details, etc.).
Docs for tuning logging in Prefect 3: Logging customization (Prefect 3)
If you share how you’re starting the Podman container (command or compose file), I can give you an exact one-liner to enable server DEBUG logs.