<@ULVA73B9P> I'm having an issue using Prefect Clo...
# ask-marvin
s
@Marvin I'm having an issue using Prefect Cloud where I'm unable to see logs for runs for tasks. I have set up logging using
logger = get_run_logger()
and have verified the level is correct. This is a recent issue- it worked correctly a few months ago
m
thought for 341.1 seconds
Thanks for the details — let’s narrow this down. A few focused checks usually uncover why task logs stop showing up in Cloud. First, a couple quick confirmations: - Are flow-level logs visible and it’s specifically task logs that are missing? - In the Cloud UI, on the Flow Run’s Logs tab, is the filter set to include task/child logs? (There’s a filter/toggle that can hide task logs.) Key things to verify in your runtime environment (assuming Prefect 3.x): 1) Make sure
get_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:
Copy code
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:
Copy 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:
Copy code
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.