Thread
#prefect-community
    Billy McMonagle

    Billy McMonagle

    10 months ago
    If I wanted to log flow run information in a custom way, is there a built-in or supported way to do this?
    I am migrating a new flow to prefect and my legacy code has a little decorator that logs "flow runs" (start, stop, final state) to a database. I probably don't want or need to port this functionality into my prefect code (bc Cloud handles it for me), but I'm curious if I could.
    Kevin Kho

    Kevin Kho

    10 months ago
    What are you thinking? Like attaching a file handler or sending it somewhere? Do you mean logging more stuff, changing the content of the logs, or outputting it somewhere?
    Billy McMonagle

    Billy McMonagle

    10 months ago
    More like a database entry (say my own postgres db)... flow name (or id), flow run id, and start time, etc
    Not "logs" per se
    Kevin Kho

    Kevin Kho

    10 months ago
    Ohh you can just log it by logging it from the context. Or am I missing something?
    Billy McMonagle

    Billy McMonagle

    10 months ago
    I might be describing it poorly. I guess I'm really asking is there a way for me to backup my flow run history somewhere other than wherever prefect cloud is storing it?
    Obviously I could write some job to query the prefect api and then write to whatever database I wished, which seems more trouble than it's worth so I don't plan to do that.
    Kevin Kho

    Kevin Kho

    10 months ago
    Ah ok. The quick answer then is not immediately. You’d need a job of sorts for sure. Unless you use the Flow state handler and context to write them out somewhere
    Billy McMonagle

    Billy McMonagle

    10 months ago
    Yea flow state handler makes sense. That would actually work well. Probably not worth the trouble though. Thanks!!