For Prefect 2: Is there a recommended way/best practice to generate logs from within one of my own modules? The modules are not contained in their own packages, they're just .py files in a folder (everything that's packaged seems to log properly). The modules are made up of some pretty big classes and functions and ideally these modules should not have any prefect dependencies. Unless there's no other way, then we'll have to live with it. 🙂
I'm probably missing something obvious, I don't have that much experience with the various ways you can set up Python loggers. I couldn't get this working using PREFECT_LOGGING_EXTRA_LOGGERS, but perhaps I've just set up my modules incorrectly.
✅ 1
a
Anna Geller
08/20/2022, 7:54 PM
Hi @Oscar Björhn, PREFECT_LOGGING_EXTRA_LOGGERS is the right way to approach it and it should work, if it doesn't, we need to open a GitHub issue and fix it. Would you be willing to write a minimal reproducible example and open an issue?
o
Oscar Björhn
08/20/2022, 9:54 PM
Thanks!
No, I'll spend some more time trying to get it to work first, I think I must be doing something wrong. You saying that the extra loggers-config is the way to go should be enough help, now I know it's not a dead end. If it doesn't seem possible, I'll put something together and open an issue, of course.
a
Anna Geller
08/20/2022, 11:05 PM
That's amazing! When setting up extra loggers, just make sure this should be configured as a comma delimited string:
export PREFECT_LOGGING_EXTRA_LOGGERS='loggername1,loggername2'
o
Oscar Björhn
08/21/2022, 9:12 AM
Will do, thanks!
Yeah, this seems to work flawlessly. Awesome, that's very handy!
I was being lazy and trying to set the environment variable using os.environ.update, which didn't seem to have an effect. Doing it properly solved the problem. :gratitude-thank-you: