Richard Sundqvist
10/17/2025, 1:18 PMprefect.get_run_logger() no longer send any logs to the API after upgrading from prefect 2.20.16 to prefect 3.4.24. Do you have to explicitly configure API logging in Prefect 3?Marvin
10/17/2025, 1:18 PMMarvin
10/17/2025, 1:25 PMget_run_logger() logs to the API by default. You do not have to explicitly enable it.
In Prefect 3.x, API logging is controlled by the logging.to_api settings and is enabled by default:
- Profile key: logging.to_api.enabled (default: true)
- Env var: PREFECT_LOGGING_TO_API_ENABLED=true
How to verify quickly:
- Show your current config (and defaults)
prefect config view --show-defaults
Look for:
logging.to_api.enabled = true
- If it’s false, enable it:
prefect config set logging.to_api.enabled=true
Or via env var:
export PREFECT_LOGGING_TO_API_ENABLED=true
Other settings you can tune (all have env var equivalents):
- logging.to_api.batch_interval → PREFECT_LOGGING_TO_API_BATCH_INTERVAL (default 2.0s)
- logging.to_api.batch_size → PREFECT_LOGGING_TO_API_BATCH_SIZE
- logging.to_api.max_log_size → PREFECT_LOGGING_TO_API_MAX_LOG_SIZE
- logging.to_api.when_missing_flow → PREFECT_LOGGING_TO_API_WHEN_MISSING_FLOW (default warn)
If logs still aren’t appearing, check these common gotchas:
- Make sure you’re calling get_run_logger() inside a running flow or task. Outside a run context, logs won’t be associated with a flow run.
- Ensure your process doesn’t exit before logs flush. Logs are batched; if you have very short-lived runs, try lowering the batch interval:
prefect config set logging.to_api.batch_interval=0.2
- Confirm you’re pointed at a Prefect 3-compatible API (Prefect Cloud or a Prefect 3 server) and that your PREFECT_API_URL and any auth are set.
- Check you aren’t overriding Prefect’s logging with a custom logging config that removes the API handler. Look for logging.config_path in prefect config view.
Docs for details:
- Logging in flows/tasks and `get_run_logger()`: Prefect 3 API: loggers
- Logging to the API settings: Settings reference and Logging customization
- Handlers (including API log handler): Logging handlers
If you can share:
- prefect version
- prefect config view --hide-defaults
- Whether you’re on Prefect Cloud or a self-hosted server (and its version)
I can pinpoint why the logs aren’t making it to the API in your environment.