Hello, in Orion - how to handle logging from pytho...
# prefect-community
d
Hello, in Orion - how to handle logging from python files which are not part of flow code? I usually use loguru for my logging but not able to make it work with Prefect logging seamlessly. I would like to have both prefect logging and app logging to sink to same target (file/console) and with consistent format. Are there any good examples available on this ?
k
Prefect 1 has extra loggers where you could attach your logger name as an env variable. I think there will be functionality to add loggers in the same way. For loguru though where it kind of collects everything, are you trying to get them all in the Prefect UI? Or all to somewhere like a file or DataDog?
a
For Prefect 2.0, you may try:
Copy code
export PREFECT_LOGGING_EXTRA_LOGGERS=loguru
but loguru is quite specific as it would require you to add Prefect logger as loguru's sink - check out this Discourse topic for using loguru in Prefect 1.0: https://discourse.prefect.io/t/can-i-use-loguru-logs-in-prefect-flows/140 and for logging in Prefect 2.0, check this great blog post: https://www.prefect.io/blog/logs-the-prefect-way/
upvote 2
147 Views