Hi all! I see a feature for logging stdout to the ...
# ask-community
h
Hi all! I see a feature for logging stdout to the cloud console, but is there a similar feature for stderr? I’m trying to integrate Prefect into a codebase with a lot of existing C++ utilities that use glog for logging, and I’m having trouble getting the logs for these utils to show up in the console.
k
Hey @hunter, I think the answer here is unfortunately not. You could open a feature request in the repo, but I don’t know when the team would get to it. It also seems like extra loggers won’t work because I assume those logs are not the Python logger. I’ll look into it a bit and see what I find
h
Yeah exactly I looked at extra loggers but it didn’t look like it would fit without a lot of hacking 😞 That’s unfortunate, but thank you for checking.
Hm. It looks like it might be an easy change…
k
What do you think of something like this if you can get the Prefect logger and add a handler?
Copy code
root = logging.getLogger()
handler = logging.StreamHandler(sys.stderr)
root.addHandler(handler)
h
Ooh. That might work too, I can give that a go. Does that need to be done on every task, or is there a way to set some kind of handler once on the flow?
Slash what are best practices for extra loggers if I’m uploading my Flows via pickle?
k
I believe every task if you store your flow in pickle based storage. It might work on the flow level if you store your flow in script based storage.
h
That’s what I figured. I’ll take a look. Thanks for these resources 🙂
k
I have a snippet for a FileHandler is it helps here
🙌 1