https://prefect.io logo
a

Alexander Kloumann

01/21/2022, 2:53 PM
Just arrived! First question here. I am trying to figure out Prefect logging using the documentation here: https://docs.prefect.io/core/concepts/logging.html#logging-from-tasks But when I add this to one of my tasks and run it I see no log file:
Copy code
logger = prefect.context.get("logger")
<http://logger.info|logger.info>("An info message.")
I tried running it from the interface on Prefect Cloud but that doesn't do anything either. What am I missing here?
k

Kevin Kho

01/21/2022, 2:55 PM
Hi @Alexander Kloumann, welcome! This won’t come out as a log file. It will appear in the Prefect logs in the UI.
a

Alexander Kloumann

01/21/2022, 2:56 PM
Thanks! And where do I find that? I'm looking at the flow in Prefect Cloud and don't see it there.
k

Kevin Kho

01/21/2022, 2:57 PM
In the Flow Run page -> Logs
a

Alexander Kloumann

01/21/2022, 2:57 PM
Thanks @Kevin Kho!
k

Kevin Kho

01/21/2022, 2:57 PM
1
a

Alexander Kloumann

01/21/2022, 3:40 PM
@Kevin Kho I was wondering also if it's possible to generate log files locally
k

Kevin Kho

01/21/2022, 3:42 PM
Something like this
👍 1
s

Sam Thomas

01/31/2022, 5:09 PM
Piggybacking on this. If I want to write the logs from all the tasks in a flow to one file does this mean I need to add the filehandler to the logger at the top of every task? If so is there a way of storing the name of that file in a flow-wide variable, e.g. if I want the logfile to be named after the time that the flow started, how does each task know the name of the file?
k

Kevin Kho

01/31/2022, 5:22 PM
Every task OR if you use script-based storage , it will be created at the start of the Flow because the script is ran
4 Views