Shefali Dahiya
10/21/2025, 8:11 PMlogger = get_run_logger() and have verified the level is correct. This is a recent issue- it worked correctly a few months agoMarvin
10/21/2025, 8:11 PMMarvin
10/21/2025, 8:17 PMget_run_logger() is called inside a running task/flow
- Calling it at import time or outside the task function won’t attach to a run context and logs will be dropped.
2) Confirm logging-to-API is enabled and not overridden
- Check your effective settings:
prefect config view
Look for:
- PREFECT_LOGGING_TO_API_ENABLED = true
- PREFECT_LOGGING_TO_API_BATCH_INTERVAL (default 2.0s) — logs can take a moment to appear
- PREFECT_LOGGING_TO_API_MAX_LOG_SIZE (default 1_000_000 bytes) — single log lines larger than this are dropped
- PREFECT_LOGGING_ROOT_LEVEL (default INFO) — lower levels are filtered out
- PREFECT_LOGGING_TO_API_WHEN_MISSING_FLOW (default 'warn') — if set to 'ignore', logs without context are silently dropped
- If you use a custom logging config (~/.prefect/logging.yml or PREFECT_LOGGING_SETTINGS_PATH), ensure the APILogHandler is still attached to the root/run loggers; a custom config can accidentally remove it and prevent logs from reaching Cloud.
3) Sanity check with a minimal task
- This verifies the runtime environment vs. your app code:
from prefect import flow, task, get_run_logger
@task
def t():
logger = get_run_logger()
<http://logger.info|logger.info>("Hello from task")
return 1
@flow(log_prints=True)
def f():
logger = get_run_logger()
<http://logger.info|logger.info>("Hello from flow")
return t()
if __name__ == "__main__":
f()
- If flow logs appear but not the task log, it points to context or logging configuration issues in your environment.
4) Confirm the logs exist via CLI (bypasses UI filtering)
- Get the task run ID from the UI or prefect task-run ls, then:
prefect task-run logs <task_run_id>
- If they show up here but not in the UI’s flow log view, it’s likely a filter/toggle issue.
5) Consider process lifecycle
- If the process/worker is terminated abruptly (SIGKILL, container stop without graceful shutdown), batched logs may not flush. If this started recently, check if your worker image or orchestration changed to stop jobs more aggressively.
6) Size/volume of logs
- Very large single log messages (> 1 MB) are dropped.
- An extremely high volume of small logs may be delayed due to batching.
If you can share a bit more, I can pinpoint it faster:
- Prefect version for your code and worker/infra
- Worker type (e.g., Docker, Kubernetes) and any recent image/runtime changes
- Whether flow logs are visible but task logs are not
- A short snippet showing how/where you call get_run_logger() in the task
- Whether you’re using a custom logging config file
Lastly, I’m not aware of a recent regression specifically affecting task run logs in Cloud. If you can provide an approximate date/time when you noticed the change, we can also check for any relevant Cloud incidents.
Happy to dig in with your details and get this sorted quickly.