Oliver Tedder
01/15/2025, 3:34 PMget_run_logger()
from within every flow and task to get a new logger? or can i just call it once from the flow and pass it down to the tasks?Marvin
01/15/2025, 3:34 PMget_run_logger()
function is designed to be used within the context of a flow or task. It provides a logger instance that is aware of the specific run context, which allows for more detailed and contextual logging. This means that it should ideally be called within each flow and task to ensure that the logger is properly contextualized for each run.
Passing a logger from a flow to a task might not capture the specific context of the task run, which could potentially lead to less useful logs when inspecting them through the Prefect UI or API.
For more details on logging in Prefect, you can refer to the Prefect logging documentation.
If you want to use a normal Python logger without Prefect's run context, you can use get_logger()
from prefect.logging
, but this logger will not send log records to the Prefect API.
If you have further questions or need examples, feel free to ask!Kevin Grismore
01/15/2025, 3:41 PMKevin Grismore
01/15/2025, 3:44 PMfrom prefect import get_run_logger as prefect_logger
and call chaining
prefect_logger().info("log this")
Oliver Tedder
01/15/2025, 4:01 PM