<@ULVA73B9P> Issue Description: I am attempting to set the logging level to `DEBUG` for a Prefect fl...
g
@Marvin Issue Description: I am attempting to set the logging level to
DEBUG
for a Prefect flow run. I have configured the
PREFECT_LOGGING_LEVEL
environment variable in my
prefect.yaml
deployment configuration, but
logger.debug()
messages from
get_run_logger()
are still not appearing in the flow run logs. Only
INFO
level and higher are visible. Deployment Configuration (
prefect.yaml
):
Copy code
yaml
deployments:
- name: Morning Reminders
  # ... other settings
  env:
    PREFECT_LOGGING_LEVEL: "DEBUG"
Troubleshooting Steps Already Taken: 1. Verified the
prefect.yaml
syntax is correct. 2. Re-applied the deployment to the server using the
prefect deploy
command. 3. Confirmed in the Prefect UI that the
PREFECT_LOGGING_LEVEL: "DEBUG"
variable is present in the deployment's configuration details. 4. Checked the flow's Python code (
main.py
) and confirmed there are no manual overrides, such as
logging.basicConfig()
. 5. Restarted the worker process. Despite these steps, the debug logs are not being displayed. Please advise on potential causes or further troubleshooting steps.
m
thought for 432.5 seconds
Thanks for the detailed write-up — that helps a lot. A few things to check for Prefect 3.x: 1) Make sure the UI is not filtering out DEBUG - In the Flow Run’s Logs tab, use the Level filter and ensure DEBUG is included. It’s easy to miss that the UI can filter by level and sometimes defaults to showing INFO+. 2) Verify the flow run actually sees PREFECT_LOGGING_LEVEL=DEBUG - Add a quick check at the very top of your flow to confirm the settings inside the run process:
Copy code
from prefect import flow, get_run_logger
from prefect.settings import get_current_settings

@flow
def debug_check():
    s = get_current_settings()
    logger = get_run_logger()
    <http://logger.info|logger.info>(f"Prefect logging level seen by flow: {s.logging.level}")
    logger.debug("This is a DEBUG message from get_run_logger()")

if __name__ == "__main__":
    debug_check()
- Run a new deployment-based run and confirm you see: - An INFO log line showing
Prefect logging level seen by flow: DEBUG
- The subsequent DEBUG log line 3) Confirm the ENV is attached to the flow runtime (not just the worker) - In Prefect 3.x,
deployments[].env
in
prefect.yaml
is applied to the flow run’s execution environment. You’ve confirmed the variable appears in the deployment details in the UI, which is good — but for Docker/Kubernetes work pools, a custom job template could accidentally omit or overwrite env. If you’re using Docker/K8s, double-check your work pool job template merges deployment env into the job/container environment. If you’re using a Process worker, it should “just work”. 4) Sanity check via CLI - After triggering a run, you can also confirm the backend has DEBUG logs with:
Copy code
prefect flow-run logs <flow_run_id> --tail
If DEBUG lines show here but not in the UI, it’s definitely the UI filter. 5) No separate “server” log level - There isn’t a
PREFECT_LOGGING_SERVER_LEVEL
setting in Prefect 3.x. The main setting to raise verbosity is
PREFECT_LOGGING_LEVEL
. The API log submission is enabled by default; since you’re seeing INFO logs already, that’s working. 6) If you need more control - You can supply a custom logging config via
PREFECT_LOGGING_CONFIG_PATH
(maps to
logging.config_path
) to explicitly set handler levels (e.g., console and API handler) to DEBUG if you suspect a handler-level gate. This is generally not needed, but it’s available. If you try the snippet in #2 and don’t see
DEBUG
in the printed settings, that means the env var isn’t actually present in the run environment — in that case, let me know: - Which worker type you’re using (Process, Docker, Kubernetes)? - If Docker/K8s, please share whether you’ve customized the work pool job template. Helpful docs: - Add logging to flows - Advanced logging customization - prefect.yaml reference
g
For those who might see this, the only thing that worked was going into the work pool I was using, editing it (I did it in the UI), and adding
Copy code
{
  "PREFECT_LOGGING_LEVEL": "DEBUG"
}
in the Base Job Template -> Environment Variables (Optional) Environment variables to set when starting a flow run.