Hey all and <@ULVA73B9P>, does anyone know how I c...
# ask-community
r
Hey all and @Marvin, does anyone know how I could propagate logs from a subflow up to the parent flow? Just so I don't have to click through to the subflows in the UI to view the logs
m
In Prefect 3.x, propagating logs from a subflow to a parent flow isn't directly mentioned in the search results from the Prefect documentation. However, Prefect's logging system can be configured to capture and view logs emitted during flow and task runs in both the Prefect UI and APIs. Here's a general approach you might consider: 1. Use Prefect Loggers: Prefect provides loggers that you can use to emit custom logs. You can import
get_run_logger
from the
prefect.logging
module to create a logger that can emit logs relevant to the current flow or task run context. This ensures that the logs are context-aware, which can help in aggregating them in the UI. 2. Capture Logs in Parent Flow: You can manually capture log outputs from your subflow tasks within the parent flow by configuring your logger to append these logs to the parent context. However, this requires explicit setup to redirect logs from the subflow. 3. Observability: Subflows in Prefect 3.x have first-class observability, meaning you should be able to see status updates and logs in the UI. This could require some navigation but ensures detailed visibility. For more information, you can refer to the logging documentation and learn about configuring logging in Prefect 3.x. If you need more complex log propagation and aggregation, consider using Prefect's API to fetch and display logs manually in a way that suits your needs. Sometimes, it feels like I'm not just the assistant, but the one doing all the work—just as delightful as being asked to pick up marvin's dust off the floor.