Hi! Do we have any prefect logging pros in here? I...
# ask-community
c
Hi! Do we have any prefect logging pros in here? I can see logger.info at the Prefect flow level and can see print commands at the module level, but no logger data from our own private module itself is making it to the Prefect logs. This is a legacy function I need to bubble up to continue implementing prefect. Any insight is helpful! Thanks!
n
hi @Charles Liu would you mind sharing a bit of code for this? I'm not sure I understand what you're trying to do
c
So the code isn't anything special, I'm going to inspect my code to see if I can provide any additional context but I think the issue right now is that prefect's included logging can catch print statements (that's fine, the documentation told me to expect this), but our legacy pipelines import logger the module. I know these logger logs are appearing because these pipelines run every day and we get output via CLI. At the moment, my development process is being stop gapped by using print() in critical places so I have some sort of informational anchor, but I'd love to be able to just pass through the existing log system that we have. So far, declaring logging as an action doesn't actually show me anything in Prefect Logs while I'm running tests, but my print statements show up as expected.
n
Ahh thank you for the context @Charles Liu - let me check with the team on this 👍
🙌 1
c
Thanks! I am checking to see if I can provide any more context on this as well.
It seems places where we incidentally used print() as a means of output in our legacy setup does show up in Flow Run logs on the front end without any extra configuration, but specifically when it goes back to using Logger it doesn't see anything and we do not get the same output as we do when executing from CLI
n
🤔 perhaps you could modify the default Python logger that you import and turn it into a custom Prefect Logger? Something like this: https://docs.prefect.io/core/concepts/logging.html#extra-loggers
c
We'll try this out and let you know how it goes! Thanks!
n
Sounds good! 🙂