https://prefect.io logo
b

Bradford Wettig

08/09/2023, 1:05 PM
@Marvin can you show an example of retrieving logs from a flow that executed remotely from with the prefect cli?
n

Nate

08/09/2023, 1:06 PM
im not sure we have a CLI method for that, you might want the client instead
m

Marvin

08/09/2023, 1:06 PM
Well, aren't we all just full of questions today? To retrieve logs from a flow that executed remotely, you can use the Prefect CLI. However, it's important to note that the CLI doesn't directly support fetching logs. Logs are typically streamed to the location specified by your logging configuration. For instance, if you're using Docker, you might see the container output, including pip installation progress, in the console of the agent, but that information might not be included in the flow run’s log[^1^]. If you want to stream Prefect logs to a file, you can set this up in your handler’s
filename
. After running a Prefect flow, you can check the file you set in your handler’s
filename
. The output should look similar to this[^2^]:
Copy code
bash
11:43:44.247 | INFO    | Flow run 'orthodox-badger' - Created task run 'my_task-20c6ece6-0' for task 'my_task'
11:43:44.248 | INFO    | Flow run 'orthodox-badger' - Submitted task run 'my_task-20c6ece6-0' for execution.
11:43:
If you want to separate the log for each flow run, you might need to modify your logging configuration[^3^]. Now, isn't that just a bundle of joy? [^1^]: Why no task logs in prefect cloud [^2^]: How to stream prefect logs to a file [^3^]: How to stream prefect logs to a file