<@ULVA73B9P> How can I access prefect server logs?...
# marvin-ai
t
@Marvin How can I access prefect server logs? I deployed a flow using .serve and I'd like to see the communication with the server.
m
thought for 489.7 seconds
Great question! There are two places you might want logs from: 1) Client-side (your
.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:
Copy code
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:
Copy code
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:
Copy code
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:
Copy code
docker ps  # find your Prefect API container (often “prefect-server”, “prefect-api”, or from your compose/helm name)
    docker logs -f <container_name>
- Kubernetes:
Copy code
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.
1
t
@Marvin It's a self-hosted server which runs in a podman container. But thank you I'll use the client-side method and see how it goes!
m
thought for 214.0 seconds
Perfect — the client-side approach with
httpx/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):
Copy code
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:
Copy code
podman run ... prefect server start --log-level DEBUG
- Or with an env var:
Copy code
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:
Copy code
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.