It seems like logs emitted by a subflow aren't pro...
# ask-community
c
It seems like logs emitted by a subflow aren't propagated to the parent flow; i.e. I can't see the subflow logs from the logs view of the parent flow - is there anyway I can get those logs propagated up?
👀 1
k
you can actually pass the logger object acquired from the parent flow into the subflow and just use it
c
could you give me a quick example or point at some docs please?
k
Copy code
from prefect import flow, get_run_logger

@flow
def parent_flow():
    logger = get_run_logger()
    child_flow(logger)

@flow
def child_flow(logger):
    <http://logger.info|logger.info>("Logs to parent flow")
I think something like this would work. there are other ways to do it that require a little more code
c
ok cool - lemme try the suggested
wish I could so something like this instead:
Copy code
logger = get_logger(use_parent=True)
@Kevin Grismore somewhat tangential, but when I run
Copy code
from prefect import flow, get_run_logger, task


@task
def parent_task():
    logger = get_run_logger()
    foo = child_flow()
    <http://logger.info|logger.info>(foo)


@flow
def child_flow():
    return "child flow"


@flow
def parent_flow():
    parent_task()


if __name__ == "__main__":
    parent_flow()
I'm seeing in the UI that there is not line/arrow linking the task to the subflow - is that expected? It doesn't make it clear visually that the task is upstream of the generated subflow
k
tasks being able to run flows is a pretty new thing! we don't have any way to display this in the UI just yet
c
oh 🙂 didn't know, alrighty cool