Gustavo Mateus
09/11/2025, 10:11 PMDEBUG 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):
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.Marvin
09/11/2025, 10:11 PMMarvin
09/11/2025, 10:18 PMfrom 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:
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 referenceGustavo Mateus
09/11/2025, 10:38 PM{
"PREFECT_LOGGING_LEVEL": "DEBUG"
}
in the Base Job Template -> Environment Variables (Optional)
Environment variables to set when starting a flow run.